Bug 246264 - [plan][annotations] VerifyError - annotation value binding when doubly annotated method-execution join point
Summary: [plan][annotations] VerifyError - annotation value binding when doubly annota...
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 1.6.2   Edit
Assignee: aspectj inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-09-04 14:55 EDT by Andrew Clement CLA
Modified: 2008-09-04 15:07 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 Andrew Clement CLA 2008-09-04 14:55:25 EDT
This code == bangbang

----8<-----
enum Color {R,G,B;}
@interface I { public Color a(); }
@interface J { public Color b() default Color.B; }


public class A {
  @J
  @I(a=Color.R)
  public static void main(String []argv) {
  }
}

aspect X {

  before(Color var): execution(* main(..)) && @annotation(I(var)) {
    if (var!=Color.R) {
      throw new RuntimeException("Wrong! Was "+var);
    }
  }
}

----8<-----
Exception in thread "main" java.lang.VerifyError: (class: A, method: main signat
ure: ([Ljava/lang/String;)V) Incompatible object argument for function call
Comment 1 Andrew Clement CLA 2008-09-04 15:07:39 EDT
No attempt is made to check the annotation we are grabbing the Color from - we go through all those on the join point and pull out a Color from any we find.  We should be checking the type matches first! In this case that the annotation is of type 'I' before we pull out its Color value.

The fix is in AnnotationAccessFieldVar.

Testcase and fix committed.

(The verifyerror happened because two Colors were put on the stack and when the advice method was called we tried to call it on the enum type rather than the aspect instance!)