Skip to content

Commit

Permalink
[GR-58596] Fix duplicate class definition attempts for generated type…
Browse files Browse the repository at this point in the history
…-mapped proxies.

PullRequest: graal/18929
  • Loading branch information
javeleon committed Oct 2, 2024
2 parents edc1423 + 2e336c3 commit 4daeafd
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,21 @@ private static Klass lookupOrDefineInBindingsLoader(EspressoForeignProxyGenerato

Symbol<Symbol.Type> proxyName = context.getTypes().fromClassGetName(proxyBytes.name);
Klass proxyKlass = registry.findLoadedKlass(context.getClassLoadingEnv(), proxyName);
if (proxyKlass == null) {
try {
proxyKlass = registry.defineKlass(context, proxyName, proxyBytes.bytes);
} catch (EspressoClassLoadingException e) {
throw EspressoError.shouldNotReachHere(e);
if (proxyKlass != null) {
return proxyKlass;
}
// double-checked locking on the proxy name
synchronized (proxyName) {
proxyKlass = registry.findLoadedKlass(context.getClassLoadingEnv(), proxyName);
if (proxyKlass == null) {
try {
proxyKlass = registry.defineKlass(context, proxyName, proxyBytes.bytes);
} catch (EspressoClassLoadingException e) {
throw EspressoError.shouldNotReachHere(e);
}
}
return proxyKlass;
}
return proxyKlass;
}

private static ObjectKlass fillParents(Object metaObject, InteropLibrary interop, PolyglotTypeMappings mappings, Set<ObjectKlass> parents, EspressoContext context) throws ClassCastException {
Expand Down

0 comments on commit 4daeafd

Please sign in to comment.