Summary: | [1.5][compiler] Constants initilialization doesn't work inside Annotation | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | David Audel <david_audel> | ||||||
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | CC: | kent_johnson, Olivier_Thomann | ||||||
Version: | 3.1 | ||||||||
Target Milestone: | 3.1.1 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows 2000 | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
David Audel
2005-08-29 09:11:05 EDT
If the annotation is converted to an interface, it works fine. According to the specs, there is no need to have a constant expression as the initialization of such a field. The field simply needs to be initialized. The treatement should be the same as the field for an interface. Such a field without an initialization should report the error: The blank final field ... may not have been initialized and not the error : The annotation field ... must be initialized with a constant expression I will attach a patch that makes the handling of annotations close to the one of interfaces. Created attachment 26601 [details]
Proposed fix
Created attachment 26602 [details]
Regression test
All tests passed. This could be a candidate for 3.1.1. Why does the patch remove the check for annotation type constructor ? These are still forbidden. Ok, it actually moves it elsewhere, to match the interface handling. This is good, though not mandated by this defect. +1 for 3.1.1. Patch looks mostly just fine. Will integrate and adjust a little. Will also add test for recovery of local annotation type decl. Kent - in BinaryTypeBinding constructor, why do we have only ? // TODO (kent) what about ANNOTATION_TYPE_DECL case ? if (binaryType.getKind() == IGenericType.INTERFACE_DECL) this.modifiers |= AccInterface; Feels like annotation type case is not handled. But, do we need this statement at all ? Modifiers should already contain the information I suppose. Fixed. Added AnnotationTest#test177, AnnotationDietRecoveryTest#test0010. Updated impacted existing tests. (did not touch BinaryTypeBinding for now) Verified in I20050921-0010 for 3.2M2 Verified using M20050923-1430 for 3.1.1 |