Bug 96991 - [1.5][compiler] Annotation attribute should be able to reference field
Summary: [1.5][compiler] Annotation attribute should be able to reference field
Status: CLOSED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 RC2   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-27 10:54 EDT by Frederic Fusier CLA
Modified: 2005-06-10 11:06 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 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