Bug 86291

Summary: [1.5][compiler] Annotation attribute see members of the annotated type
Product: [Eclipse Project] JDT Reporter: David Audel <david_audel>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: thanson
Version: 3.0   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description David Audel CLA 2005-02-23 11:45:37 EST
build I20050219 + jdtcore head

1) create p/Annot.java
package p;
public @interface Annot {
  String foo1() default "";
}

2) create p2/X.java
package p2;
import p.Annot;
@Annot(foo1=zzz)
public class X {
  static final String zzz =  "";
}
3) compile

there is no error but javac found an error

p2\X.java:5: cannot find symbol
symbol: variable zzz
@Annot(foo1=zzz)
            ^
1 error
Comment 1 Olivier Thomann CLA 2005-02-24 10:18:43 EST
It appears that zzz needs to be qualified.

@Annot(foo1=X.zzz)
public class X {
  static final String zzz =  "";
}
compiles fine with javac.
Comment 2 David Audel CLA 2005-02-24 10:32:10 EST
similar bug with qualification and private field.

@Annot(foo1=X.zzz)
public class X {
  private static final String zzz = "";
}

javac found an error and not jdt compiler

p2\X.java:5: zzz has private access in p2.X
@Annot(foo1=X.zzz)
             ^
1 error
Comment 3 Philipe Mulet CLA 2005-03-14 06:56:17 EST
Added AnnotationTest#test112 & test114 & test115.
Introduced MethodScope#insideTypeAnnotation to be able to exclude offending
constructs (type, method and field) from lookup algorithm.
Curiously, javac allows resolving method annotation to method type parameters or
parameters; which sounds inconsistent; which we also allow as well.

Fixed
Comment 4 Philipe Mulet CLA 2005-03-18 19:43:32 EST
*** Bug 88506 has been marked as a duplicate of this bug. ***
Comment 5 David Audel CLA 2005-03-31 10:19:00 EST
Verified in I20050330-0500