RFR 7183985: Class.getAnnotation() throws an ArrayStoreException when the annotation class not present
Joel Borggrén-Franck
joel.borggren.franck at gmail.com
Tue Jan 5 21:16:56 UTC 2016
Hi Liam,
I think you need to do skipMemberValue the correct number of times so
that the cursor in buf is correct, or?
I modified your test slightly to provoke an
AnnotationTypeMismatchException that I think shouldn't be there:
@AnnotationAnnotation({@ClassArrayAnnotation({Missing.class, String.class}),
@ClassArrayAnnotation({String.class})})
public class F {}
and
@Retention(RUNTIME)
public @interface AnnotationAnnotation {
ClassArrayAnnotation[] value();
}
giving:
java.lang.RuntimeException:
java.lang.annotation.AnnotationTypeMismatchException: Incorrectly
typed data found for annotation element public abstract
ClassArrayAnnotation[] AnnotationAnnotation.value() (Found data of
type Array with component tag: 99)
Also, in MissingArrayElementTest, why not just rethrow t?
52 if (t.getClass() != EnumConstantNotPresentException.class) {
53 System.err.printf(
54 "expected %s, saw %s\n",
EnumConstantNotPresentException.class, t);
55 throw new RuntimeException(t);
56 }
cheers
/Joel
On Mon, Dec 21, 2015 at 9:42 PM, Liam Miller-Cushon <cushon at google.com> wrote:
> If an annotation value is an array of class literals or enum constants,
> calling Class.getAnnotation() fails with ArrayStoreException if the element
> type is not found.
>
> This patch implements the proposed fix from the bug thread, which allows
> getAnnotation() to succeed and a TypeNotPresentException to be thrown from
> Annotation.value().
>
> bug: https://bugs.openjdk.java.net/browse/JDK-7183985
>
> The patch is attached.
More information about the core-libs-dev
mailing list