From ed9fe2bcb3a99b8adc1f5ae53bf88659d47d2f7d Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 19 Mar 2013 14:59:33 -0700 Subject: [PATCH] 8001309: Better handling of annotation interfaces Reviewed-by: ahgross, smarks, alanb --- .../reflect/annotation/AnnotationInvocationHandler.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java b/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java index d3cff5716ef..6e73de70d52 100644 --- a/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java +++ b/jdk/src/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -337,12 +337,15 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable { try { annotationType = AnnotationType.getInstance(type); } catch(IllegalArgumentException e) { - // Class is no longer an annotation type; all bets are off - return; + // Class is no longer an annotation type; time to punch out + throw new java.io.InvalidObjectException("Non-annotation type in annotation serial stream"); } Map> memberTypes = annotationType.memberTypes(); + + // If there are annotation members without values, that + // situation is handled by the invoke method. for (Map.Entry memberValue : memberValues.entrySet()) { String name = memberValue.getKey(); Class memberType = memberTypes.get(name);