本文整理汇总了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"));
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}