Skip to content

Commit a007df9

Browse files
committed
associate the MethodHandles with classloader which loaded jruby - fixes #2091
the static MethodHandles#publicLookup does not work when the JVM has two (or more) classloaders where jruby is running in - the lookup uses Object.class as "reference". to separate the jitted methods the lookup needs to be on a per classloader level. since Ruby.class is different when coming from different classloaders it is used to separate the lookup of MethodHandles.
1 parent 5749171 commit a007df9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

core/src/main/java/org/jruby/compiler/JITCompiler.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ public void run() {
247247
// only variable-arity
248248
method.switchToJitted(
249249
new CompiledIRMethod(
250-
MethodHandles.publicLookup().findStatic(sourceClass, jittedName, signatures.get(-1)),
250+
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
251251
method.getIRMethod(),
252252
method.getVisibility(),
253253
method.getImplementationClass()));
@@ -258,8 +258,8 @@ public void run() {
258258

259259
method.switchToJitted(
260260
new CompiledIRMethod(
261-
MethodHandles.publicLookup().findStatic(sourceClass, jittedName, signatures.get(-1)),
262-
MethodHandles.publicLookup().findStatic(sourceClass, jittedName, entry.getValue()),
261+
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
262+
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, entry.getValue()),
263263
entry.getKey(),
264264
method.getIRMethod(),
265265
method.getVisibility(),

0 commit comments

Comments
 (0)