Type annotations (JSR 308) specification draft

Alex Buckley alex.buckley at oracle.com
Thu Jan 24 11:50:11 PST 2013

On the one hand, post-parameter [] is "obsolescent" and shouldn't be 
encouraged by supporting it in new language features. It's not hard to 
move the [] which are part of the return type to their proper syntactic 
location if you want to annotate them.

On the other hand, post-parameter [] is legal and causes no standard 
compile-time warning. Weasel words in the JLS about "should not be used" 
can be ignored without penalty, so I assume someone does ignore them. 
Bottom line, it's a first-class language feature in Java SE 7, and it's 
not on the table for removal in Java SE 8, so if Mike wants to let it be 
annotated (to avoid rewriting legacy code), that's fine with me.


On 1/24/2013 11:08 AM, Michael Ernst wrote:
> Srikanth-
> My first reaction is that it would surprise programmers for type
> annotations to be permitted in some locations that are legal Java but
> forbidden in other locations that are legal Java.  Furthermore, a
> programmer may want to add type annotations to a legacy Java program
> without being forced to rewrite the Java program.  The programmer may not
> wish to rewrite the program simply because any rewriting, however minor,
> carries a risk of error.
> If the JLS required a Java compiler to issue a warning for the obsolescent
> usage, then that would encourage programmers to rewrite their code and I
> would be more in favor of not supporting type annotations there.
> I'd like to hear others' opinions as well.
> 		    -Mike
>> Subject: Re: Type annotations (JSR 308) specification draft
>> From: Srikanth S Adayapalam <srikanth_sankaran at in.ibm.com>
>> To: Michael Ernst <mernst at cs.washington.edu>
>> Date: Thu, 24 Jan 2013 12:59:03 +0530
>> JLS8 8.4 states:
>> For compatibility with older versions of the Java SE platform, the declaration of
>> a
>> method that returns an array is allowed to place (some or all of) the empty
>> bracket
>> pairs that form the declaration of the array type after the formal parameter
>> list. This
>> is supported by the following obsolescent production, but should not be used in
>> new code.
>> ---------------
>> Given that it could be argued that it does not make sense to allow for
>> annotations to
>> be specified in the extra dimensions. Can we simply get rid of the changes in the
>> grammar for MethodDeclaratorRest and InterfaceMethodDeclaratorRest ?
>> Is there a compelling reason to support a discouraged construct ? It would
>> simplify
>> our implementation a bit if we don't have to.
>> Thanks!
>> Srikanth

More information about the type-annotations-spec-experts mailing list