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


Java LambdaConversionException类代码示例

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


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

示例1: testReturnVoidDef

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
public void testReturnVoidDef() {
    assumeFalse("JDK is JDK 9", Constants.JRE_IS_MINIMUM_JAVA9);
    Exception expected = expectScriptThrows(LambdaConversionException.class, () -> {
        exec("StringBuilder b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);");
    });
    assertThat(expected.getMessage(), containsString("Type mismatch for lambda expected return: void is not convertible to long"));

    expected = expectScriptThrows(LambdaConversionException.class, () -> {
        exec("def b = new StringBuilder(); def l = [1, 2]; l.stream().mapToLong(b::setLength);");
    });
    assertThat(expected.getMessage(), containsString("Type mismatch for lambda expected return: void is not convertible to long"));

    expected = expectScriptThrows(LambdaConversionException.class, () -> {
        exec("def b = new StringBuilder(); List l = [1, 2]; l.stream().mapToLong(b::setLength);");
    });
    assertThat(expected.getMessage(), containsString("Type mismatch for lambda expected return: void is not convertible to long"));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:FunctionRefTests.java

示例2: amf

import java.lang.invoke.LambdaConversionException; //导入依赖的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: mf

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
private static boolean mf(MethodHandles.Lookup l) {
    try {
        LambdaMetafactory.metafactory(l, "close",
            mt(Closeable.class),mt(void.class),h,mt(void.class));
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:T8032704.java

示例4: mf

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
private static boolean mf(Class<?> k) {
    try {
        LambdaMetafactory.metafactory(l, "m",
            mt(I.class),mt(k),h,mt(void.class));
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:10,代码来源:T8032711.java

示例5: mf

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:9,代码来源:T8032697.java

示例6: createCallSite

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
private static CallSite createCallSite(String signatureName, MethodHandles.Lookup lookup, MethodHandle methodHandle,
		MethodType instantiatedMethodType, MethodType signature, Class<?> interfaceClass) throws LambdaConversionException {
	return LambdaMetafactory.metafactory(
			lookup, 
			signatureName,
			MethodType.methodType(interfaceClass), 
			signature, 
			methodHandle, 
			instantiatedMethodType);
}
 
开发者ID:Hervian,项目名称:lambda-factory,代码行数:11,代码来源:LambdaFactory.java

示例7: buildFactory

import java.lang.invoke.LambdaConversionException; //导入依赖的package包/类
private void buildFactory(String name, MethodHandles.Lookup caller, MethodType fact, MethodType getter) throws LambdaConversionException, IllegalAccessException {
	CallSite site = LambdaMetafactory.metafactory(caller, name, fact, getter, target, getter);
	factory = site.getTarget();
}
 
开发者ID:warriordog,项目名称:BlazeLoader,代码行数:5,代码来源:FuncHandle.java


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