mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8199567: [Nestmates] Cleanup instanceKlass.cpp
Reviewed-by: lfoltan, coleenp
This commit is contained in:
parent
34397c4914
commit
c145bd0bd0
1 changed files with 24 additions and 14 deletions
|
@ -165,25 +165,35 @@ bool InstanceKlass::has_nest_member(InstanceKlass* k, TRAPS) const {
|
|||
k->external_name(), this->external_name());
|
||||
}
|
||||
|
||||
// Check names first and if they match then check actual klass. This avoids
|
||||
// resolving anything unnecessarily.
|
||||
// Check for a resolved cp entry , else fall back to a name check.
|
||||
// We don't want to resolve any class other than the one being checked.
|
||||
for (int i = 0; i < _nest_members->length(); i++) {
|
||||
int cp_index = _nest_members->at(i);
|
||||
Symbol* name = _constants->klass_name_at(cp_index);
|
||||
if (name == k->name()) {
|
||||
log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
|
||||
// names match so check actual klass - this may trigger class loading if
|
||||
// it doesn't match (but that should be impossible)
|
||||
if (_constants->tag_at(cp_index).is_klass()) {
|
||||
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
||||
if (k2 == k) {
|
||||
log_trace(class, nestmates)("- class is listed as a nest member");
|
||||
log_trace(class, nestmates)("- class is listed at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
return true;
|
||||
} else {
|
||||
// same name but different klass!
|
||||
log_trace(class, nestmates)(" - klass comparison failed!");
|
||||
// can't have different classes for the same name, so we're done
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Symbol* name = _constants->klass_name_at(cp_index);
|
||||
if (name == k->name()) {
|
||||
log_trace(class, nestmates)("- Found it at nest_members[%d] => cp[%d]", i, cp_index);
|
||||
|
||||
// names match so check actual klass - this may trigger class loading if
|
||||
// it doesn't match (but that should be impossible)
|
||||
Klass* k2 = _constants->klass_at(cp_index, CHECK_false);
|
||||
if (k2 == k) {
|
||||
log_trace(class, nestmates)("- class is listed as a nest member");
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
// same name but different klass!
|
||||
log_trace(class, nestmates)(" - klass comparison failed!");
|
||||
// can't have two names the same, so we're done
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue