RFR 7183985: Class.getAnnotation() throws an ArrayStoreException when the annotation class not present

Liam Miller-Cushon cushon at google.com
Sun Feb 25 01:14:55 UTC 2018

Hi, thanks for the comments.

The updated webrev is at:

On Fri, Feb 23, 2018 at 4:29 PM, Joseph D. Darcy <joe.darcy at oracle.com>

> Objects implementing the AnnotatedElement interface are also created in
> javac during annotation processing. As a secondary concern, it would be
> good to be have behavior between both javac and runtime annotations
> consistent when possible. (My own to-do list includes at least once such
> alignment JDK-8164819: "Make javac's toString() on annotation objects
> consistent with core reflection".)

Do you have a pointer to where that happens? There's javax.lang.model.
AnnotatedConstruct#getAnnotation, which isn't affected by this issue--it
throws MirroredTypesExceptionProxy when accessing an annotation value that
is an array of class literals, regardless of whether the elements' classes
are missing. I'm not seeing implementations of AnnotatedElement in

> Even in javac we've moved away from test and directory names based on
> bugid. I'd recommend incorporating these regression tests into the existing
> tests in
>     test/jdk/java/lang/annotation/Missing

Thanks for the reminder, done.

> It would be worth verifying whether or not this change also covers
> java.lang.reflect.Executable.getParameterAnnotations(), more specifically
> the implementation of that method in Method and Constructor. The method
> getParameterAnnotations() is much less used than getAnnotations and the
> other methods on the AnnotatedElement interface, but still part of the
> annotations feature.


> (As a follow-up refactoring, it might be worthwhile to replace the
> interior of the three parseFooArray methods to a shared method that is
> passed a lambda for the "Object value = parseFooValue(/*args to get
> foo*/...);" logic.)

Sounds good, I filed: https://bugs.openjdk.java.net/browse/JDK-8198669

More information about the core-libs-dev mailing list