Skip to content

Commit

Permalink
[GR-58221] Improve nest support.
Browse files Browse the repository at this point in the history
PullRequest: graal/18836
  • Loading branch information
gilles-duboscq committed Sep 25, 2024
2 parents fcbe904 + a634290 commit e64ace9
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ public Klass nest() {
host = thisPool.resolvedKlassAt(this, nestHost.hostClassIndex);
} catch (AbstractTruffleException e) {
if (getJavaVersion().java15OrLater()) {
getContext().getLogger().log(Level.FINE, "Exception while loading nest host class for " + this.getExternalName(), e);
getContext().getLogger().log(Level.FINE, e, () -> "Exception while loading nest host class for " + this.getExternalName());
// JVMS sect. 5.4.4: Any exception thrown as a result of failure of class or
// interface resolution is not rethrown.
host = this;
Expand All @@ -904,7 +904,7 @@ public Klass nest() {
}
if (host != this && !host.nestMembersCheck(this)) {
if (getJavaVersion().java15OrLater()) {
getContext().getLogger().log(Level.FINE, "Failed nest host class checks for " + this.getExternalName());
getContext().getLogger().log(Level.FINE, () -> "Failed nest host class checks for " + this.getExternalName());
host = this;
} else {
Meta meta = getMeta();
Expand All @@ -930,9 +930,7 @@ public boolean nestMembersCheck(Klass k) {
RuntimeConstantPool pool = getConstantPool();
for (int index : nestMembers.getClasses()) {
if (k.getName().equals(pool.classAt(index).getName(pool))) {
if (k == pool.resolvedKlassAt(this, index)) {
return true;
}
return true;
}
}
return false;
Expand Down Expand Up @@ -983,14 +981,22 @@ public Klass[] getNestMembers() {
klasses.add(nest());
for (int i = 0; i < nestMembers.getClasses().length; i++) {
int index = nestMembers.getClasses()[i];
Klass k;
try {
klasses.add(pool.resolvedKlassAt(this, index));
} catch (EspressoException e) {
k = pool.resolvedKlassAt(this, index);
} catch (AbstractTruffleException e) {
/*
* Don't allow badly constructed nest members to break execution here, only report
* well-constructed entries.
*/
getContext().getLogger().log(Level.FINE, e, () -> "Exception while loading nest host class for " + this.getExternalName());
continue;
}
if (k.nest() != this) {
getContext().getLogger().log(Level.FINE, () -> "Skipping nest member with a different nest host class for " + this.getExternalName() + " member " + k + " with host " + k.nest());
continue;
}
klasses.add(k);
}
return klasses.toArray(Klass.EMPTY_ARRAY);
}
Expand Down

0 comments on commit e64ace9

Please sign in to comment.