Skip to content

Commit 66d9961

Browse files
committed
8205502: Make exception message from AnnotationInvocationHandler more informative
Reviewed-by: bpb, naoto, iris
1 parent 5e59d28 commit 66d9961

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/java.base/share/classes/sun/reflect/annotation/AnnotationInvocationHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ class AnnotationInvocationHandler implements InvocationHandler, Serializable {
5252
if (!type.isAnnotation() ||
5353
superInterfaces.length != 1 ||
5454
superInterfaces[0] != java.lang.annotation.Annotation.class)
55-
throw new AnnotationFormatError("Attempt to create proxy for a non-annotation type.");
55+
throw new AnnotationFormatError("Attempt to create proxy for a non-annotation type: " +
56+
type.getName());
5657
this.type = type;
5758
this.memberValues = memberValues;
5859
}
@@ -492,7 +493,9 @@ private void validateAnnotationMethods(Method[] memberMethods) {
492493
* 9.6.1. Annotation Type Elements
493494
*/
494495
boolean valid = true;
496+
Method currentMethod = null;
495497
for(Method method : memberMethods) {
498+
currentMethod = method;
496499
int modifiers = method.getModifiers();
497500
// Skip over methods that may be a static initializer or
498501
// similar construct. A static initializer may be used for
@@ -575,7 +578,8 @@ private void validateAnnotationMethods(Method[] memberMethods) {
575578
if (valid)
576579
return;
577580
else
578-
throw new AnnotationFormatError("Malformed method on an annotation type");
581+
throw new AnnotationFormatError("Malformed method on an annotation type: " +
582+
currentMethod.toString());
579583
}
580584

581585
/**

0 commit comments

Comments
 (0)