Type annotations (JSR 308) specification draft

Michael Ernst mernst at cs.washington.edu
Thu Jan 24 11:08:37 PST 2013


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.


> 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