8270404: Better canonicalization

Reviewed-by: coleenp, rhalade, mschoene
This commit is contained in:
Harold Seigel 2021-07-26 17:32:18 +00:00 committed by Henry Jen
parent 24b588eddb
commit 76373ae3c8
2 changed files with 19 additions and 0 deletions

View File

@ -3141,6 +3141,13 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(const ClassFileStrea
valid_klass_reference_at(outer_class_info_index),
"outer_class_info_index %u has bad constant type in class file %s",
outer_class_info_index, CHECK_0);
if (outer_class_info_index != 0) {
const Symbol* const outer_class_name = cp->klass_name_at(outer_class_info_index);
char* bytes = (char*)outer_class_name->bytes();
guarantee_property(bytes[0] != JVM_SIGNATURE_ARRAY,
"Outer class is an array class in class file %s", CHECK_0);
}
// Inner class name
const u2 inner_name_index = cfs->get_u2_fast();
check_property(

View File

@ -3066,6 +3066,18 @@ InstanceKlass* InstanceKlass::compute_enclosing_class(bool* inner_is_member, TRA
constantPoolHandle i_cp(THREAD, constants());
if (ooff != 0) {
Klass* ok = i_cp->klass_at(ooff, CHECK_NULL);
if (!ok->is_instance_klass()) {
// If the outer class is not an instance klass then it cannot have
// declared any inner classes.
ResourceMark rm(THREAD);
Exceptions::fthrow(
THREAD_AND_LOCATION,
vmSymbols::java_lang_IncompatibleClassChangeError(),
"%s and %s disagree on InnerClasses attribute",
ok->external_name(),
external_name());
return NULL;
}
outer_klass = InstanceKlass::cast(ok);
*inner_is_member = true;
}