8271968: Better canonical naming

Reviewed-by: coleenp, lfoltan, mschoene, ahgross
This commit is contained in:
Harold Seigel 2021-08-11 16:48:14 +00:00 committed by Henry Jen
parent 7ee905a8a0
commit 1fddb03d93

View File

@ -3051,6 +3051,7 @@ static int inner_classes_jump_to_outer(const Array<u2>* inner_classes, int inner
static bool inner_classes_check_loop_through_outer(const Array<u2>* inner_classes, int idx, const ConstantPool* cp, int length) {
int slow = inner_classes->at(idx + InstanceKlass::inner_class_inner_class_info_offset);
int fast = inner_classes->at(idx + InstanceKlass::inner_class_outer_class_info_offset);
while (fast != -1 && fast != 0) {
if (slow != 0 && (cp->klass_name_at(slow) == cp->klass_name_at(fast))) {
return true; // found a circularity
@ -3080,14 +3081,15 @@ bool ClassFileParser::check_inner_classes_circularity(const ConstantPool* cp, in
for (int y = idx + InstanceKlass::inner_class_next_offset; y < length;
y += InstanceKlass::inner_class_next_offset) {
// To maintain compatibility, throw an exception if duplicate inner classes
// entries are found.
guarantee_property((_inner_classes->at(idx) != _inner_classes->at(y) ||
_inner_classes->at(idx+1) != _inner_classes->at(y+1) ||
_inner_classes->at(idx+2) != _inner_classes->at(y+2) ||
_inner_classes->at(idx+3) != _inner_classes->at(y+3)),
"Duplicate entry in InnerClasses attribute in class file %s",
CHECK_(true));
// 4347400: make sure there's no duplicate entry in the classes array
if (_major_version >= JAVA_1_5_VERSION) {
guarantee_property((_inner_classes->at(idx) != _inner_classes->at(y) ||
_inner_classes->at(idx+1) != _inner_classes->at(y+1) ||
_inner_classes->at(idx+2) != _inner_classes->at(y+2) ||
_inner_classes->at(idx+3) != _inner_classes->at(y+3)),
"Duplicate entry in InnerClasses attribute in class file %s",
CHECK_(true));
}
// Return true if there are two entries with the same inner_class_info_index.
if (_inner_classes->at(y) == _inner_classes->at(idx)) {
return true;
@ -3180,10 +3182,9 @@ u2 ClassFileParser::parse_classfile_inner_classes_attribute(const ClassFileStrea
inner_classes->at_put(index++, inner_access_flags.as_short());
}
// 4347400: make sure there's no duplicate entry in the classes array
// Also, check for circular entries.
// Check for circular and duplicate entries.
bool has_circularity = false;
if (_need_verify && _major_version >= JAVA_1_5_VERSION) {
if (_need_verify) {
has_circularity = check_inner_classes_circularity(cp, length * 4, CHECK_0);
if (has_circularity) {
// If circularity check failed then ignore InnerClasses attribute.