8266766: Arrays of types that cannot be an annotation member do not yield exceptions

Reviewed-by: darcy, jfranck
This commit is contained in:
Rafael Winterhalter 2021-06-10 12:02:53 +00:00 committed by Joel Borggrén-Franck
parent d43c8a74b3
commit 09243822eb
2 changed files with 142 additions and 2 deletions

View file

@ -528,10 +528,11 @@ public class AnnotationParser {
} else if (componentType.isEnum()) {
return parseEnumArray(length, (Class<? extends Enum<?>>)componentType, buf,
constPool, container);
} else {
assert componentType.isAnnotation();
} else if (componentType.isAnnotation()) {
return parseAnnotationArray(length, (Class <? extends Annotation>)componentType, buf,
constPool, container);
} else {
return parseUnknownArray(length, buf);
}
}
@ -753,6 +754,18 @@ public class AnnotationParser {
return (exceptionProxy != null) ? exceptionProxy : result;
}
private static Object parseUnknownArray(int length,
ByteBuffer buf) {
int tag = 0;
for (int i = 0; i < length; i++) {
tag = buf.get();
skipMemberValue(tag, buf);
}
return exceptionProxy(tag);
}
/**
* Returns an appropriate exception proxy for a mismatching array
* annotation where the erroneous array has the specified tag.