Queries about JDK-8035890
Alex Buckley
alex.buckley at oracle.com
Fri Mar 28 19:57:26 UTC 2014
On 3/28/2014 7:47 AM, Werner Dietl wrote:
> Alex, Jan,
>
>>> These are supposed to be invalid:
>>> public class Foo {
>>> <T> @DA Foo() { }
>>> <T> @TA Foo(int i) { }
>>> }
>>
>> Ah, constructor declarations. The EG never discussed allowing
>> annotations after the type parameter section there. I guess that was an
>> oversight, but as things stand your two ctors are invalid.
>
> For consistency, shouldn't the last line be allowed?
>
> @TA Foo(int i) { }
>
> is legal, as is
>
> @TA Object bar(int i) { ... }
>
> Adding type parameters to the method doesn't change it's legality and
>
> <T> @TA Object bar(int i) { ... }
>
> is still legal.
> So why should doing the same with a ctor be illegal?
Because JLS8 says it is illegal. If you want to respecify the Java
language in JLS9 to allow annotations after the type parameter section
of a ctor declaration, then you will need to file a
specification/language bug at bugs.openjdk.java.net, and a corresponding
tools/javac bug. (You're a Committer on an OpenJDK Project, so you can
do this.)
Alex
More information about the type-annotations-dev
mailing list