当前位置: 首页>>代码示例>>Java>>正文


Java LambdaMetafactory.altMetafactory方法代码示例

本文整理汇总了Java中java.lang.invoke.LambdaMetafactory.altMetafactory方法的典型用法代码示例。如果您正苦于以下问题:Java LambdaMetafactory.altMetafactory方法的具体用法?Java LambdaMetafactory.altMetafactory怎么用?Java LambdaMetafactory.altMetafactory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.invoke.LambdaMetafactory的用法示例。


在下文中一共展示了LambdaMetafactory.altMetafactory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import java.lang.invoke.LambdaMetafactory; //导入方法依赖的package包/类
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");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:18,代码来源:LambdaReceiverBridge.java

示例2: amf

import java.lang.invoke.LambdaMetafactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:12,代码来源:LambdaReturn.java

示例3: testAltStdNonser

import java.lang.invoke.LambdaMetafactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:SerializedLambdaTest.java

示例4: testAltStdSer

import java.lang.invoke.LambdaMetafactory; //导入方法依赖的package包/类
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);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:16,代码来源:SerializedLambdaTest.java


注:本文中的java.lang.invoke.LambdaMetafactory.altMetafactory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。