Bug 108377 - Verify Error on intertype field indirection in intertype method
Summary: Verify Error on intertype field indirection in intertype method
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: 1.5.0M3   Edit
Hardware: PC Linux
: P1 normal (vote)
Target Milestone: 1.5.0 M4   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-30 11:01 EDT by Aske Simon Christensen CLA
Modified: 2005-08-31 09:21 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.