JEP 120: Repeating Annotations
Joseph Darcy
joe.darcy at oracle.com
Fri Jan 6 17:50:20 PST 2012
On 1/6/2012 9:48 AM, Jesse Glick wrote:
> On 01/05/2012 06:32 PM, Joe Darcy wrote:
>> other consumers of class files don't have to have extensive
>> modifications.
>
> If there are other class file parsers which assume (contrary to the
> current JVM spec!) that only one annotation of a given type is present
> on a given element, they would need to be fixed - e.g. using a list or
> multimap rather than a map, or simply ignoring second and subsequent
> occurrences if irrelevant for their use case. This does not feel like
> "extensive modifications", especially if compared to other likely
> class file changes such as for lambdas, but it is true that it is a
> change when compared to JDK 7 (at least when restricted to class files
> produced by javac).
>
>> any solution to repeating annotations that did not acknowledge and
>> leverage this situation is unlikely to have speedy adoption.
>
> Well assuming that the code which reads the annotation
> (elt.getAnnotation(Thing.class)) is in the same overall source project
> as the definition of the annotation itself (Thing.java), which is
> typical, and assuming that this feature is targeted for JDK 8, there
> are several cases:
This will not be the typically arrangement for, say, enterprise apps
using Java EE standard annotations, many of which use the
container-annotation work around to get the effect of repeating annotations.
I do not think it is prudent to require that code that reads and
interprets those annotations to be updated to a new idiom before the
improved syntax can be used in clients.
-Joe
More information about the compiler-dev
mailing list