JDK-5014480 : javac incorrectly accepts obsolescent array return type on annotation elements
  • Type: Bug
  • Component: specification
  • Sub-Component: language
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2004-03-16
  • Updated: 2009-01-06
  • Resolved: 2009-01-06
Related Reports
Duplicate :  
Description
To: ###@###.###
From: <###@###.###>
Subject: [metadata-jsr] Clarifications for dimensions in the AnnotationTypeMemberDeclaration

Hi,

The latest version of javac (javac 1.5.0-beta2/build 1.5.0-beta2-b42) 
accepts this code:

@interface Name {
        String first()[];
        String last();
}

In the public draft, I can read:

        AbstractMethodModifiersopt Type Identifier ( ) DefaultValueopt ;

This means that the [] are illegal. The only possible tokens after ')' are 
'default' or ';'.

The rule should be written like this, if you want to allow the brackets.

AbstractMethodModifiersopt Type Identifier ( ) Dimsopt DefaultValueopt ;

Could you please let me know if the specs will be updated to reflect the 
rule above or if this is a bug in the compiler? The code could easily be 
fixed like this:

@interface Name {
        String[] first();
        String last();
}

Comments
EVALUATION javac 1.6 still accepts the obsolescent array syntax, so practically speaking, the JLS will have to change to allow such syntax in annotation types' method declarations. See the master grammar bug 6442525.
07-12-2006

EVALUATION Fixing this later would introduce an incompatibility, so it should be addressed in Tiger. ###@###.### 2004-03-16 For consitency with other syntactic entities in the language, perhaps the spec should be changed to allow the obsolescent array syntax. ###@###.### 2004-08-03
16-03-2004