Java Code Examples for java.lang.invoke.CallSite

The following examples show how to use java.lang.invoke.CallSite. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: presto   Source File: LambdaCapture.java    License: Apache License 2.0 6 votes vote down vote up
public static CallSite lambdaCapture(
        MethodHandles.Lookup callerLookup,
        String name,
        MethodType type,
        MethodType samMethodType,
        MethodHandle implMethod,
        MethodType instantiatedMethodType)
{
    try {
        // delegate to metafactory, we may choose to generate code ourselves in the future.
        return LambdaMetafactory.metafactory(
                callerLookup,
                name,
                type,
                samMethodType,
                implMethod,
                instantiatedMethodType);
    }
    catch (LambdaConversionException e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
Example 2
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiverBridge.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X,
                                      LambdaMetafactory.FLAG_BRIDGES, 1, A);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 3
private static void testAutoLoadedLinkerInvoked(final Object target, final String methodName) {
    final DynamicLinkerFactory factory = newDynamicLinkerFactory(false);
    final DynamicLinker linker = factory.createLinker();

    // we should still get one error due to untrusted dynamic linker exporter!
    checkOneAutoLoadingError(factory);

    final MethodType mt = MethodType.methodType(Object.class, Object.class);
    final CallSiteDescriptor testDescriptor = new CallSiteDescriptor(MethodHandles.publicLookup(),
            GET.withNamespace(StandardNamespace.METHOD).named(methodName), mt);
    final CallSite cs = linker.link(new SimpleRelinkableCallSite(testDescriptor));

    TrustedGuardingDynamicLinkerExporter.enable();
    try {
        cs.getTarget().invoke(target);
        // The linker was loaded and it observed our invocation
        Assert.assertTrue(TrustedGuardingDynamicLinkerExporter.isLastCallSiteDescriptor(testDescriptor));
    } catch (final Throwable th) {
        throw new RuntimeException(th);
    } finally {
        TrustedGuardingDynamicLinkerExporter.disable();
    }

}
 
Example 4
Source Project: jdk8u-dev-jdk   Source File: LambdaReceiver.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiver.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 5
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiverBridge.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X,
                                      LambdaMetafactory.FLAG_BRIDGES, 1, A);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 6
Source Project: jdk8u-jdk   Source File: LambdaReceiver.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiver.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 7
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiverBridge.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X,
                                      LambdaMetafactory.FLAG_BRIDGES, 1, A);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 8
private static void relinkComposableInvoker(final CallSite cs, final CompiledFunction inv, final boolean constructor) {
    final HandleAndAssumptions handleAndAssumptions = inv.getValidOptimisticInvocation(new Supplier<MethodHandle>() {
        @Override
        public MethodHandle get() {
            return inv.getInvokerOrConstructor(constructor);
        }
    });
    final MethodHandle handle = handleAndAssumptions.handle;
    final SwitchPoint assumptions = handleAndAssumptions.assumptions;
    final MethodHandle target;
    if(assumptions == null) {
        target = handle;
    } else {
        final MethodHandle relink = MethodHandles.insertArguments(RELINK_COMPOSABLE_INVOKER, 0, cs, inv, constructor);
        target = assumptions.guardWithTest(handle, MethodHandles.foldArguments(cs.dynamicInvoker(), relink));
    }
    cs.setTarget(target.asType(cs.type()));
}
 
Example 9
@SuppressWarnings("unchecked")
public static <T> T createLambda(Object instance, Method instanceMethod, Class<?> functionalIntfCls) {
  try {
    Method intfMethod = findAbstractMethod(functionalIntfCls);
    MethodHandle methodHandle = LOOKUP.unreflect(instanceMethod);

    MethodType intfMethodType = MethodType.methodType(intfMethod.getReturnType(), intfMethod.getParameterTypes());
    MethodType instanceMethodType = MethodType
        .methodType(instanceMethod.getReturnType(), instanceMethod.getParameterTypes());
    CallSite callSite = LambdaMetafactory.metafactory(
        LOOKUP,
        intfMethod.getName(),
        MethodType.methodType(functionalIntfCls, instance.getClass()),
        intfMethodType,
        methodHandle,
        instanceMethodType);

    return (T) callSite.getTarget().bindTo(instance).invoke();
  } catch (Throwable e) {
    throw new IllegalStateException("Failed to create lambda from " + instanceMethod, e);
  }
}
 
Example 10
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiver.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 11
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiverBridge.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.altMetafactory(l, "m", mti,X,h,X,
                                      LambdaMetafactory.FLAG_BRIDGES, 1, A);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 12
Source Project: jdk8u_jdk   Source File: LambdaReceiver.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiver.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 13
Source Project: openjdk-jdk9   Source File: LambdaReceiver.java    License: GNU General Public License v2.0 6 votes vote down vote up
public static void main(String[] args) throws Throwable {
    l = MethodHandles.lookup();
    h = l.findVirtual(LambdaReceiver_A.class, "f", mt(int.class));
    MethodType X = mt(int.class, LambdaReceiver.class);
    MethodType A = mt(int.class, LambdaReceiver_A.class);
    MethodType mti = mt(IA.class);
    CallSite cs = LambdaMetafactory.metafactory(l, "m", mti,A,h,X);
    IA p = (IA)cs.dynamicInvoker().invoke();
    LambdaReceiver_A lra = new LambdaReceiver_A();
    try {
        p.m(lra);
    } catch (ClassCastException cce) {
        return;
    }
    throw new AssertionError("CCE expected");
}
 
Example 14
Source Project: openjdk-jdk9   Source File: BeanLinkerTest.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Test(dataProvider = "flags")
public void systemLoadLibraryTest(final boolean publicLookup) {
    final CallSite cs1 = createGetMethodCallSite(publicLookup, "loadLibrary");
    final CallSite cs2 = createCallSite(publicLookup, CALL, MethodType.methodType(void.class, Object.class, Object.class, String.class));

    try {
        final Object method = cs1.getTarget().invoke(StaticClass.forClass(System.class));
        cs2.getTarget().invoke(method, StaticClass.forClass(System.class), "foo");
        throw new RuntimeException("should not reach here in any case!");
    } catch (final Throwable th) {
        if (publicLookup) {
            Assert.assertTrue(th instanceof IllegalAccessError);
        } else {
            Assert.assertTrue(th instanceof AccessControlException);
        }
    }
}
 
Example 15
private static void relinkComposableInvoker(final CallSite cs, final CompiledFunction inv, final boolean constructor) {
    final HandleAndAssumptions handleAndAssumptions = inv.getValidOptimisticInvocation(new Supplier<MethodHandle>() {
        @Override
        public MethodHandle get() {
            return inv.getInvokerOrConstructor(constructor);
        }
    });
    final MethodHandle handle = handleAndAssumptions.handle;
    final SwitchPoint assumptions = handleAndAssumptions.assumptions;
    final MethodHandle target;
    if(assumptions == null) {
        target = handle;
    } else {
        final MethodHandle relink = MethodHandles.insertArguments(RELINK_COMPOSABLE_INVOKER, 0, cs, inv, constructor);
        target = assumptions.guardWithTest(handle, MethodHandles.foldArguments(cs.dynamicInvoker(), relink));
    }
    cs.setTarget(target.asType(cs.type()));
}
 
Example 16
Source Project: openjdk-jdk9   Source File: Method.java    License: GNU General Public License v2.0 6 votes vote down vote up
private Handle generateBootstrapMethod(Handle h) {
    String bootstrapName = "bootstrapMethod";
    MethodType bootstrapType = MethodType.methodType(CallSite.class, MethodHandles.Lookup.class, String.class, MethodType.class);

    MethodVisitor bmv = cv.visitMethod(ACC_PUBLIC | ACC_STATIC, bootstrapName, bootstrapType.toMethodDescriptorString(), null, null);
    bmv.visitCode();

    String constCallSite = "java/lang/invoke/ConstantCallSite";
    bmv.visitTypeInsn(NEW, constCallSite);
    bmv.visitInsn(DUP);

    bmv.visitLdcInsn(h);

    bmv.visitMethodInsn(INVOKESPECIAL, constCallSite, "<init>", "(Ljava/lang/invoke/MethodHandle;)V", false);
    bmv.visitInsn(ARETURN);

    bmv.visitMaxs(0,0);
    bmv.visitEnd();

    return new Handle(H_INVOKESTATIC, ownerClassName, bootstrapName, bootstrapType.toMethodDescriptorString());
}
 
Example 17
@Test
public void prelinkTransformerTest() throws Throwable {
    final DynamicLinkerFactory factory = newDynamicLinkerFactory(true);
    final boolean[] reachedPrelinkTransformer = { false };

    factory.setPrelinkTransformer((final GuardedInvocation inv, final LinkRequest linkRequest, final LinkerServices linkerServices) -> {
        reachedPrelinkTransformer[0] = true;
        // just identity transformer!
        return inv;
    });

    final MethodType mt = MethodType.methodType(Object.class, Object.class, String.class);
    final DynamicLinker linker = factory.createLinker();
    final CallSite cs = linker.link(new SimpleRelinkableCallSite(new CallSiteDescriptor(
            MethodHandles.publicLookup(), GET_PROPERTY, mt)));
    Assert.assertFalse(reachedPrelinkTransformer[0]);
    Assert.assertEquals(cs.getTarget().invoke(new Object(), "class"), Object.class);
    Assert.assertTrue(reachedPrelinkTransformer[0]);
}
 
Example 18
Source Project: presto   Source File: Bootstrap.java    License: Apache License 2.0 5 votes vote down vote up
public static CallSite bootstrap(MethodHandles.Lookup callerLookup, String name, MethodType type, long bindingId)
{
    ClassLoader classLoader = callerLookup.lookupClass().getClassLoader();
    checkArgument(classLoader instanceof DynamicClassLoader, "Expected %s's classloader to be of type %s", callerLookup.lookupClass().getName(), DynamicClassLoader.class.getName());

    DynamicClassLoader dynamicClassLoader = (DynamicClassLoader) classLoader;
    MethodHandle target = dynamicClassLoader.getCallSiteBindings().get(bindingId);
    checkArgument(target != null, "Binding %s for function %s%s not found", bindingId, name, type.parameterList());

    return new ConstantCallSite(target);
}
 
Example 19
public void testAltStdSer() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Alt metafactory, serializable target, no FLAG_SERIALIZABLE: not serializable
    CallSite cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                                   "test", MethodType.methodType(SerPredicate.class),
                                                   predicateMT, fooMH, stringPredicateMT, 0);
    assertNotSerial((SerPredicate<String>) cs.getTarget().invokeExact(), fooAsserter);

    // Alt metafactory, serializable marker, no FLAG_SERIALIZABLE: not serializable
    cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                          "test", MethodType.methodType(Predicate.class),
                                          predicateMT, fooMH, stringPredicateMT, LambdaMetafactory.FLAG_MARKERS, 1, Serializable.class);
    assertNotSerial((Predicate<String>) cs.getTarget().invokeExact(), fooAsserter);
}
 
Example 20
Source Project: groovy   Source File: IndyInterface.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * backing bootstrap method with all parameters
 */
private static CallSite realBootstrap(Lookup caller, String name, int callID, MethodType type, boolean safe, boolean thisCall, boolean spreadCall) {
    // since indy does not give us the runtime types
    // we produce first a dummy call site, which then changes the target to one when INDY_OPTIMIZE_THRESHOLD is reached,
    // that does the method selection including the direct call to the
    // real method.
    CacheableCallSite mc = new CacheableCallSite(type);
    final Class<?> sender = caller.lookupClass();
    MethodHandle mh = makeAdapter(mc, sender, name, callID, type, safe, thisCall, spreadCall);
    mc.setTarget(mh);
    mc.setDefaultTarget(mh);
    mc.setFallbackTarget(makeFallBack(mc, sender, name, callID, type, safe, thisCall, spreadCall));

    return mc;
}
 
Example 21
public void testDirectStdSer() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Standard metafactory, serializable target: not serializable
    CallSite cs = LambdaMetafactory.metafactory(MethodHandles.lookup(),
                                                "test", MethodType.methodType(SerPredicate.class),
                                                predicateMT, fooMH, stringPredicateMT);
    assertNotSerial((SerPredicate<String>) cs.getTarget().invokeExact(), fooAsserter);
}
 
Example 22
Source Project: openjdk-jdk9   Source File: InvokeDynamic.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * A bootstrap method for invokedynamic
 * @param lookup a lookup object
 * @param methodName methodName
 * @param type method type
 * @return CallSite for method
 */
public static CallSite bootstrapMethod(MethodHandles.Lookup lookup,
        String methodName, MethodType type) throws IllegalAccessException,
        NoSuchMethodException {
    MethodType mtype = MethodType.methodType(boolean.class,
            new Class<?>[]{int.class, long.class, float.class,
                double.class, String.class});
    return new ConstantCallSite(lookup.findVirtual(lookup.lookupClass(),
            methodName, mtype));
}
 
Example 23
Source Project: hottub   Source File: SerializedLambdaTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void testDirectStdNonser() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Standard metafactory, non-serializable target: not serializable
    CallSite cs = LambdaMetafactory.metafactory(MethodHandles.lookup(),
                                                "test", MethodType.methodType(Predicate.class),
                                                predicateMT, fooMH, stringPredicateMT);
    Predicate<String> p = (Predicate<String>) cs.getTarget().invokeExact();
    assertNotSerial(p, fooAsserter);
}
 
Example 24
Source Project: groovy   Source File: IndyInterface.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @since 2.5.0
 */
public static CallSite staticArrayAccess(MethodHandles.Lookup lookup, String name, MethodType type) {
    if (type.parameterCount() == 2) {
        return new ConstantCallSite(IndyArrayAccess.arrayGet(type));
    } else {
        return new ConstantCallSite(IndyArrayAccess.arraySet(type));
    }
}
 
Example 25
public void testAltStdNonser() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Alt metafactory, non-serializable target: not serializable
    CallSite cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                                   "test", MethodType.methodType(Predicate.class),
                                                   predicateMT, fooMH, stringPredicateMT, 0);
    assertNotSerial((Predicate<String>) cs.getTarget().invokeExact(), fooAsserter);
}
 
Example 26
Source Project: TencentKona-8   Source File: Bootstrap.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Boostrapper for math calls that may overflow
 * @param lookup         lookup
 * @param name           name of operation
 * @param type           method type
 * @param programPoint   program point to bind to callsite
 *
 * @return callsite for a math intrinsic node
 */
public static CallSite mathBootstrap(final Lookup lookup, final String name, final MethodType type, final int programPoint) {
    final MethodHandle mh;
    switch (name) {
    case "iadd":
        mh = JSType.ADD_EXACT.methodHandle();
        break;
    case "isub":
        mh = JSType.SUB_EXACT.methodHandle();
        break;
    case "imul":
        mh = JSType.MUL_EXACT.methodHandle();
        break;
    case "idiv":
        mh = JSType.DIV_EXACT.methodHandle();
        break;
    case "irem":
        mh = JSType.REM_EXACT.methodHandle();
        break;
    case "ineg":
        mh = JSType.NEGATE_EXACT.methodHandle();
        break;
    default:
        throw new AssertionError("unsupported math intrinsic");
    }
    return new ConstantCallSite(MH.insertArguments(mh, mh.type().parameterCount() - 1, programPoint));
}
 
Example 27
private MethodHandle createComposableInvoker(final boolean isConstructor) {
    final MethodHandle handle = getInvokerOrConstructor(isConstructor);

    // If compiled function is not optimistic, it can't ever change its invoker/constructor, so just return them
    // directly.
    if(!canBeDeoptimized()) {
        return handle;
    }

    // Otherwise, we need a new level of indirection; need to introduce a mutable call site that can relink itself
    // to the compiled function's changed target whenever the optimistic assumptions are invalidated.
    final CallSite cs = new MutableCallSite(handle.type());
    relinkComposableInvoker(cs, this, isConstructor);
    return cs.dynamicInvoker();
}
 
Example 28
Source Project: openjdk-jdk9   Source File: BeanLinkerTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Test(dataProvider = "flags")
public void newObjectTest(final boolean publicLookup) {
    final MethodType mt = MethodType.methodType(Object.class, Object.class);
    final CallSite cs = createCallSite(publicLookup, NEW, mt);

    Object obj = null;
    try {
        obj = cs.getTarget().invoke(StaticClass.forClass(Date.class));
    } catch (final Throwable th) {
        throw new RuntimeException(th);
    }

    Assert.assertTrue(obj instanceof Date);
}
 
Example 29
public void testAltStdSer() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Alt metafactory, serializable target, no FLAG_SERIALIZABLE: not serializable
    CallSite cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                                   "test", MethodType.methodType(SerPredicate.class),
                                                   predicateMT, fooMH, stringPredicateMT, 0);
    assertNotSerial((SerPredicate<String>) cs.getTarget().invokeExact(), fooAsserter);

    // Alt metafactory, serializable marker, no FLAG_SERIALIZABLE: not serializable
    cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                          "test", MethodType.methodType(Predicate.class),
                                          predicateMT, fooMH, stringPredicateMT, LambdaMetafactory.FLAG_MARKERS, 1, Serializable.class);
    assertNotSerial((Predicate<String>) cs.getTarget().invokeExact(), fooAsserter);
}
 
Example 30
public void testAltStdNonser() throws Throwable {
    MethodHandle fooMH = MethodHandles.lookup().findStatic(SerializedLambdaTest.class, "foo", predicateMT);

    // Alt metafactory, non-serializable target: not serializable
    CallSite cs = LambdaMetafactory.altMetafactory(MethodHandles.lookup(),
                                                   "test", MethodType.methodType(Predicate.class),
                                                   predicateMT, fooMH, stringPredicateMT, 0);
    assertNotSerial((Predicate<String>) cs.getTarget().invokeExact(), fooAsserter);
}