Bug 86291 - [1.5][compiler] Annotation attribute see members of the annotated type
Summary: [1.5][compiler] Annotation attribute see members of the annotated type
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 88506 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-02-23 11:45 EST by David Audel CLA
Modified: 2005-03-31 10:19 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 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