diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java index 43cf38f12bd..7b7d7432996 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/Invokers.java @@ -394,6 +394,7 @@ class Invokers { @ForceInline void checkCustomized(Object o) { MethodHandle mh = (MethodHandle)o; + if (MethodHandleImpl.isCompileConstant(mh)) return; if (mh.form.customized == null) { maybeCustomize(mh); } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java index 57568ece696..35805a4294e 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java @@ -722,6 +722,13 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP; return result; } + // Intrinsified by C2. Returns true if obj is a compile-time constant. + @LambdaForm.Hidden + static + boolean isCompileConstant(Object obj) { + return false; + } + static MethodHandle makeGuardWithTest(MethodHandle test, MethodHandle target,