Skip to content

Commit db10c66

Browse files
committed
better keep the static nature of the MethodHandles.publicLookup
static in the sense of global lookup per classloader. related to #2091
1 parent 3bb5c15 commit db10c66

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

+8-6
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,20 @@ public void jitThresholdReached(final InterpretedIRMethod method, final RubyInst
173173
jitTask.run();
174174
}
175175
}
176-
176+
177+
private static final MethodHandles.Lookup PUBLIC_LOOKUP = MethodHandles.publicLookup().in(Ruby.class);
178+
177179
private class JITTask implements Runnable {
178180
private final String className;
179181
private final InterpretedIRMethod method;
180182
private final String methodName;
181-
183+
182184
public JITTask(String className, InterpretedIRMethod method, String methodName) {
183185
this.className = className;
184186
this.method = method;
185187
this.methodName = methodName;
186188
}
187-
189+
188190
public void run() {
189191
try {
190192
// Check if the method has been explicitly excluded
@@ -247,7 +249,7 @@ public void run() {
247249
// only variable-arity
248250
method.switchToJitted(
249251
new CompiledIRMethod(
250-
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
252+
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
251253
method.getIRMethod(),
252254
method.getVisibility(),
253255
method.getImplementationClass()));
@@ -258,8 +260,8 @@ public void run() {
258260

259261
method.switchToJitted(
260262
new CompiledIRMethod(
261-
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, signatures.get(-1)),
262-
MethodHandles.publicLookup().in(Ruby.class).findStatic(sourceClass, jittedName, entry.getValue()),
263+
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, signatures.get(-1)),
264+
PUBLIC_LOOKUP.findStatic(sourceClass, jittedName, entry.getValue()),
263265
entry.getKey(),
264266
method.getIRMethod(),
265267
method.getVisibility(),

0 commit comments

Comments
 (0)