mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8266598: Exception values for AnnotationTypeMismatchException are not always informative
Reviewed-by: jfranck
This commit is contained in:
parent
13d6180421
commit
7b1e4024c0
3 changed files with 25 additions and 13 deletions
|
@ -356,11 +356,18 @@ public class AnnotationParser {
|
|||
|
||||
if (result == null) {
|
||||
result = new AnnotationTypeMismatchExceptionProxy(
|
||||
memberType.getClass().getName());
|
||||
Proxy.isProxyClass(memberType)
|
||||
? memberType.getInterfaces()[0].getName()
|
||||
: memberType.getName());
|
||||
} else if (!(result instanceof ExceptionProxy) &&
|
||||
!memberType.isInstance(result)) {
|
||||
result = new AnnotationTypeMismatchExceptionProxy(
|
||||
result.getClass() + "[" + result + "]");
|
||||
if (result instanceof Annotation) {
|
||||
result = new AnnotationTypeMismatchExceptionProxy(
|
||||
result.toString());
|
||||
} else {
|
||||
result = new AnnotationTypeMismatchExceptionProxy(
|
||||
result.getClass().getName() + "[" + result + "]");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -463,12 +470,9 @@ public class AnnotationParser {
|
|||
String typeName = constPool.getUTF8At(typeNameIndex);
|
||||
int constNameIndex = buf.getShort() & 0xFFFF;
|
||||
String constName = constPool.getUTF8At(constNameIndex);
|
||||
if (!enumType.isEnum()) {
|
||||
if (!enumType.isEnum() || enumType != parseSig(typeName, container)) {
|
||||
return new AnnotationTypeMismatchExceptionProxy(
|
||||
typeName + "." + constName);
|
||||
} else if (enumType != parseSig(typeName, container)) {
|
||||
return new AnnotationTypeMismatchExceptionProxy(
|
||||
typeName + "." + constName);
|
||||
typeName.substring(1, typeName.length() - 1).replace('/', '.') + "." + constName);
|
||||
}
|
||||
|
||||
try {
|
||||
|
@ -755,7 +759,7 @@ public class AnnotationParser {
|
|||
*/
|
||||
private static ExceptionProxy exceptionProxy(int tag) {
|
||||
return new AnnotationTypeMismatchExceptionProxy(
|
||||
"Array with component tag: " + tag);
|
||||
"Array with component tag: " + (tag == 0 ? "0" : (char) tag));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue