Search in sources :

Example 1 with LambdaReceiver_A

use of LambdaReceiver_anotherpkg.LambdaReceiver_A in project jdk8u_jdk by JetBrains.

the class LambdaReceiver method main.

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");
}
Also used : MethodType(java.lang.invoke.MethodType) LambdaReceiver_A(LambdaReceiver_anotherpkg.LambdaReceiver_A) CallSite(java.lang.invoke.CallSite)

Example 2 with LambdaReceiver_A

use of LambdaReceiver_anotherpkg.LambdaReceiver_A in project jdk8u_jdk by JetBrains.

the class LambdaReceiverBridge method main.

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");
}
Also used : MethodType(java.lang.invoke.MethodType) LambdaReceiver_A(LambdaReceiver_anotherpkg.LambdaReceiver_A) CallSite(java.lang.invoke.CallSite)

Aggregations

LambdaReceiver_A (LambdaReceiver_anotherpkg.LambdaReceiver_A)2 CallSite (java.lang.invoke.CallSite)2 MethodType (java.lang.invoke.MethodType)2