Java Code Examples for java.lang.invoke.LambdaMetafactory#altMetafactory()
The following examples show how to use
java.lang.invoke.LambdaMetafactory#altMetafactory() .
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 File: LambdaReceiverBridge.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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 2
Source File: LambdaReceiverBridge.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
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
Source File: LambdaReceiverBridge.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
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 4
Source File: LambdaReceiverBridge.java From native-obfuscator with GNU General Public License v3.0 | 6 votes |
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 5
Source File: LambdaReceiverBridge.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
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 File: SerializedLambdaTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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 7
Source File: LambdaReturn.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 8
Source File: SerializedLambdaTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 9
Source File: SerializedLambdaTest.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
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 10
Source File: SerializedLambdaTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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 11
Source File: LambdaReturn.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 12
Source File: SerializedLambdaTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 13
Source File: SerializedLambdaTest.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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 14
Source File: LambdaReturn.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 15
Source File: LambdaReturn.java From native-obfuscator with GNU General Public License v3.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 16
Source File: SerializedLambdaTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
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 17
Source File: LambdaReturn.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 18
Source File: LambdaReturn.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
private static void amf(List<String> errs, MethodHandle h, MethodType mts, MethodType mtf, MethodType mtb, boolean shouldWork) { MethodType mti = mt(I.class); try { LambdaMetafactory.altMetafactory(l, "m", mti, mts,h,mtf, LambdaMetafactory.FLAG_BRIDGES, 1, mtb); } catch(LambdaConversionException e) { if (shouldWork) errs.add("Error: Should work h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb + " got: " + e); return; } if (!shouldWork) errs.add("Error: Should fail h=" + h + " s=" + mts + " -- f=" + mtf + " / b=" + mtb); }
Example 19
Source File: SerializedLambdaTest.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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 20
Source File: SerializedLambdaTest.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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); }