Bug 108377

Summary: Verify Error on intertype field indirection in intertype method
Product: [Tools] AspectJ Reporter: Aske Simon Christensen <aske>
Component: CompilerAssignee: Adrian Colyer <adrian.colyer>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P1    
Version: 1.5.0M3   
Target Milestone: 1.5.0 M4   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Aske Simon Christensen CLA 2005-08-30 11:01:24 EDT
When I run this program:

public class A {
    public static void main(String[] args) {
	System.out.println(new A().foo());
    }
}

aspect Aspect1 {
    public A A.a;
    public String A.value;

    public String A.foo() {
	return a.value;
    }
}

I get the error:

Exception in thread "main" java.lang.VerifyError: (class: Aspect1, method:
ajc$interMethod$Aspect1$A$foo signature: (LA;)Ljava/lang/String;) Incompatible
type for getting or setting field
        at A.<init>(A.java:1)
        at A.main(A.java:3)

Javap reveals that the field name is missing the class name part:

   1:   getfield        #50; //Field a:LA;
   4:   getfield        #46; //Field A.value:Ljava/lang/String;

If I replace a.value by this.a.value, the correct code is generated:

   1:   getfield        #37; //Field A.a:LA;
   4:   getfield        #46; //Field A.value:Ljava/lang/String;
Comment 1 Adrian Colyer CLA 2005-08-30 11:12:26 EDT
this looks serious. tagging M4 and P1
Comment 2 Adrian Colyer CLA 2005-08-31 05:16:39 EDT
The bug occurs when the JDT compiler tries to update the codegenBinding for the
field in the case that the actual receiver type != the declaring class of the
field (to preserve the receiver type in the bytecode, as per 1.4 onwards). With
an ITD, the receiver type was set to the Aspect type, and updating the
codegenBinding with the aspect as the new declaring type causes the problem. Now
looking into the cleanest fix for this in the codebase...
Comment 3 Adrian Colyer CLA 2005-08-31 09:21:48 EDT
fix now available in latest published build on the download page.