type closest to a type annotation
Alex Buckley
alex.buckley at oracle.com
Fri Feb 7 13:59:13 PST 2014
On 2/7/2014 3:19 AM, Markus Keller wrote:
> Then we better keep "closest". Counterexample:
>
> @A int[] f;
>
> "The type of the declared entity" here means "the type of variable 'f'",
> which is "int[]", but the type annotation @A applies to "int".
>
> But maybe you could add this sentence at the first occurrence of "closest"
> in 9.7.4?
>
> "The closest type is the lexically first type reference in the declared
> entity's type."
Now I remember why I wrote "closest" :-)
I'll add the text below. I had hoped to appeal to pick out the "first
lexical occurrence of a type" by building on the tokens classified as
TypeNames in 6.5.1, but that doesn't include primitive types. I'd rather
avoid the phrase "type reference" too.
--
In the second and third cases above, the type which is closest to the
annotation is determined by first taking the type of the declared
entity, then identifying the first token which itself denotes a type.
NOTE: For example, in the field declaration @Foo public static
java.lang.String f;, the type which is closest to @Foo is String. In the
generic method declaration @Foo <T> int[] m() {...}, the type of the
declared entity is int[], whose first token denoting a type is int, so
@Foo applies to the type int.
--
Alex
More information about the type-annotations-spec-comments
mailing list