[type-annos-observers] Type annotations on primitive types and void (was: JLS and JVMS changes for JSR 308)
Markus Keller
markus_keller at ch.ibm.com
Mon Oct 14 10:19:09 PDT 2013
> http://cr.openjdk.java.net/~abuckley/308.pdf
I found two more problems:
(1) "4.11 Where Types Are Used" on page 5 says: "In all the contexts above
where a type is used, it is permitted to annotate the Identifier which
denotes the simple name of the type (6.5.5.1). Annotations in these
locations are called type annotations, and are specified in 9.7."
This sounds like all types have an Identifier. But primitive types have a
keyword that can be annotated, not an Identifier.
(2) "9.7.4 Where Annotations May Appear" says "It is a compile-time error
if an annotation of type T decorates a type (or any part of
a type) in a type context (§4.11) and one of the following applies:" , but
it misses a definition for cases where an annotation doesn't decorate a
type, but the "void" keyword in the Result of a MethodDeclaration.
Example: I couldn't find anything in the 308.pdf that would make this
illegal, but on the other hand, its meaning is also not defined:
@Target(ElementType.TYPE_USE)
@interface Illegal { }
class C {
@Illegal void foo() {}
}
"9.6.3.b javadoc for java.lang.annotation.ElementType" says: "The constant
TYPE_USE corresponds to all the type contexts in JLS 4.11, as well as
all declaration contexts except package declarations." But in this
example, @Target(ElementType.TYPE_USE) effectively allows less targets
than @Target({ElementType.TYPE_USE, ElementType.METHOD}).
Markus
BTW: The concerns raised in
http://mail.openjdk.java.net/pipermail/type-annotations-spec-observers/2013-August/000179.html
have not yet been addressed in 308-20130903.pdf
More information about the type-annotations-spec-observers
mailing list