JDK-8007427 : Annotation element as '_' gives compiler error instead of a warning
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-02-01
  • Updated: 2013-06-11
  • Resolved: 2013-02-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b82Fixed
Related Reports
Relates :  
Description
Sample test case:
//Annotation with _ as one of the elements
@interface MyAnno {
    int _() default 0;
}
// Element Value pair
@MyAnno(_=2)
class test{}


Compilation output:
test.java:3: warning: '_' used as an identifier
    int _() default 0;
        ^
  (use of '_' as an identifier might not be supported in future releases)
test.java:6: warning: '_' used as an identifier
  @MyAnno(_=2)
          ^
  (use of '_' as an identifier might not be supported in future releases)
test.java:6: error: ')' expected
  @MyAnno(_=2)
           ^
test.java:6: error: class, interface, or enum expected
  @MyAnno(_=2)
            ^
test.java:6: error: class, interface, or enum expected
  @MyAnno(_=2)
             ^
3 errors
2 warnings

Errors in the above output are unexpected.

JLS rule in section 9.6 states the following:
AnnotationTypeElementDeclaration: 
AbstractMethodModifiersopt Type Identifier ( ) DefaultValueopt ;

Comments
Fix done by Maurizio as part of this changeset: http://hg.openjdk.java.net/lambda/lambda/langtools/rev/89bc9300b5e5
14-02-2013