Bug 96991

Summary: [1.5][compiler] Annotation attribute should be able to reference field
Product: [Eclipse Project] JDT Reporter: Frederic Fusier <frederic_fusier>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 RC2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Frederic Fusier CLA 2005-05-27 10:54:29 EDT
Open this bug to address unexpected compiler error for bug 89937 comment 1 test
case...
Comment 1 Philipe Mulet CLA 2005-05-27 12:26:29 EDT
Issue is:

package p2;
import p.Annot;
public class X {
  void bar(){
    @Annot(foo=zzz)
    final int zzz = 0;
  }
}

With a local variable the behavior is the opposite. Eclipse refuse the code and
produce this error message: "The value for annotation attribute Annot.foo must
be a constant expression". Javac compile this code with no error.
Comment 2 Philipe Mulet CLA 2005-06-03 06:50:39 EDT
Problem comes from the fact the local variable constant did not get computed by
the time the annotation is being resolved. Moved annotation resolution after
constant computation.

Added AnnotationTest#test149. Interestingly field cases are rejecting similar
situations as illegal forward refs which feels like locals should be the same.

Fixed
Comment 3 Frederic Fusier CLA 2005-06-07 10:12:44 EDT
Verified for 3.1 RC2 using build N20050607-0010 + JDT/Core HEAD
Comment 4 Jerome Lanneluc CLA 2005-06-10 11:06:53 EDT
Verified with I20050610-0010