Skip to content

Commit

Permalink
Use a lookup() for field access in static constant
Browse files Browse the repository at this point in the history
This field access appears to trigger a bug in Java 8 and 11 (at
least) leading to linkage errors and classes leaking across
classloaders when a method handle is resolved at static
initialization time.

See jruby#7911

The change here provides a local MethodHandles.Lookup object
rather than using a publicLookup() to acquire the field handle.
This may work around whatever the JDK bug was.

Fixes jruby#7911
  • Loading branch information
headius committed Oct 6, 2023
1 parent 852abd4 commit bc7125b
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ public static CallSite contextValueString(Lookup lookup, String name, MethodType

private static final MethodHandle RUNTIME_FROM_CONTEXT_HANDLE =
Binder
.from(Ruby.class, ThreadContext.class)
.from(LOOKUP, Ruby.class, ThreadContext.class)
.getFieldQuiet("runtime");

private static final MethodHandle NIL_HANDLE =
Expand Down

0 comments on commit bc7125b

Please sign in to comment.