Bug 265397 - [reconciling] Incorrect error reported for ITD reference
Summary: [reconciling] Incorrect error reported for ITD reference
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: UI (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: 1.6.4   Edit
Assignee: AJDT-inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-02-18 21:07 EST by Andrew Clement CLA
Modified: 2009-02-19 14:41 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Clement CLA 2009-02-18 21:07:41 EST
I am using an aspect from Ramnivas.  Here is the bit that causes a problem - I don't have a minimal testcase, you will need to install the project from ramnivas and pick up its maven deps.

public aspect BeanMakerAspect {
    private PropertyChangeSupport BeanSupport.propertyChangeSupport;
    
    public void BeanSupport.addPropertyChangeListener(
            PropertyChangeListener listener) {
        propertyChangeSupport.addPropertyChangeListener(listener);
    }            

    public void BeanSupport.removePropertyChangeListener(
            PropertyChangeListener listener) {
        propertyChangeSupport.removePropertyChangeListener(listener);
    }            

    pointcut beanCreation(BeanSupport bean) 
        : execution(BeanSupport+.new()) && this(bean);
        
    pointcut beanPropertyChange(BeanSupport bean, Object newValue) 
        : execution(* BeanSupport+.set*(..))
          && args(newValue) && this(bean);
    
    after(BeanSupport bean) returning : beanCreation(bean) {
        bean.propertyChangeSupport = new PropertyChangeSupport(bean);
    }

on that final reference to:

bean.propertyChangeSupport

I get the warning in the editor:

"bean.propertyChangeSupport cannot be resolved or is not a field"

In attempting to create a small testcase, i get this further problem:

aspect B {
	private int I.i;
	
	after(I instance): execution(* *(..)) && target(instance) {
		instance.i = 5;
	}
}

interface I {
	
}

on the line 'instance.i = 5' the editor reports "The static field I.i should be accessed in a static way"
Comment 1 Andrew Eisenberg CLA 2009-02-18 23:00:48 EST
I'll have to look into the first problem, but the second one may be difficult.  

When inserting fields into interfaces, the compiler assumes that they are public-static-final (because those are the only kinds of fields available for interfaces).  So, there is no way that I can properly handle precisely this problem before the compiler picks it up.  

However, I might be able remove the problem after the fact.  The difficulty is in removing only this kind of spurious error, but no correct errors.  
Comment 2 Andrew Eisenberg CLA 2009-02-19 13:56:12 EST
It should be possible to remove the problem after the fact if the problem occurs inside the aspect that declares the ITD.  The problem finder when it comes across this problem can look for the names of all ITDs declared in the compilation unit.  If this name matches one of those, we can remove this problem with high certainty that we are correct.

However, the field will still *look* like a static field (ie- italicized).  

Also, there is no easy way to remove this problem when it occurs outside of the compilation unit that declares the ITD.  The only thing to do would be to ignore this problem completely.  However, this would also remove an unconscionable amount of real errors (ie- all errors where a static variable is used in a non-static way).  Since this is *only* a warning, my inclination is to ignore these cases.
Comment 3 Andrew Eisenberg CLA 2009-02-19 14:09:37 EST
Fix for second part with test is committed to CVS.
Comment 4 Andrew Eisenberg CLA 2009-02-19 14:41:31 EST
The first part of this bug has been fixed and committed with a test.  No more work to do here.