package jsr292; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; // Run w/ -XX:+PrintAssembly. // testConstant() shouldn't contain any code related to MHI::maybeCustomize. public class InvokerTest { static final MethodHandle mh1; static MethodHandle mh2; static { try { mh1 = mh2 = MethodHandles.lookup().findStatic(InvokerTest.class, "f", MethodType.methodType(void.class)); } catch (Exception e) { throw new Error(e); } } static void f() {} public static void testConstant() throws Throwable { mh1.invokeExact(); } public static void testNonConstant() throws Throwable { mh2.invokeExact(); } public static void main(String[] args) throws Throwable { testConstant(); // no testNonConstant(); // } }