Repeatable non-inheritable annotation types
Alex Buckley
alex.buckley at oracle.com
Fri Jun 28 15:33:19 PDT 2013
Deven You raised the following point at [1]. Assume the declarations:
@Foo(1) @Foo(2) class A {}
class B extends A {}
where Foo is _not_ inheritable. Foo is repeatable with FooContainer as
its containing annotation type, and FooContainer _is_ inheritable.
B.class.getAnnotationsByType(FooContainer.class) will of course expose
the inherited @FooContainer annotation. But,
B.class.getAnnotationsByType(Foo.class) should not expose @Foo(1)
@Foo(2), as Foo is not inheritable.
The definitions of "present" and "associated" annotations in the spec
are correct, but this particular scenario - with a _non_-inheritable Foo
- was not covered in the examples in section 1.2.
I have extended example 1.2-1 to cover it, and updated the spec PDF at:
http://cr.openjdk.java.net/~abuckley/8misc.pdf
Alex
[1]
http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/017675.html
More information about the enhanced-metadata-spec-discuss
mailing list