Java 类java.lang.invoke.LambdaConversionException 实例源码

项目:elasticsearch_my    文件:FunctionRefTests.java   
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"));
}
项目:jdk8u-jdk    文件:LambdaReturn.java   
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);
}
项目:jdk8u-jdk    文件:T8032704.java   
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;
}
项目:jdk8u-jdk    文件:T8032711.java   
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;
}
项目:jdk8u-jdk    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:openjdk-jdk10    文件:LambdaReturn.java   
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);
}
项目:openjdk-jdk10    文件:T8032704.java   
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;
}
项目:openjdk-jdk10    文件:T8032711.java   
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;
}
项目:openjdk-jdk10    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:openjdk9    文件:LambdaReturn.java   
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);
}
项目:openjdk9    文件:T8032704.java   
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;
}
项目:openjdk9    文件:T8032711.java   
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;
}
项目:openjdk9    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:jdk8u_jdk    文件:LambdaReturn.java   
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);
}
项目:jdk8u_jdk    文件:T8032704.java   
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;
}
项目:jdk8u_jdk    文件:T8032711.java   
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;
}
项目:jdk8u_jdk    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:lookaside_java-1.8.0-openjdk    文件:LambdaReturn.java   
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);
}
项目:lookaside_java-1.8.0-openjdk    文件:T8032704.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:T8032711.java   
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;
}
项目:lookaside_java-1.8.0-openjdk    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:lambda-factory    文件:LambdaFactory.java   
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);
}
项目:infobip-open-jdk-8    文件:LambdaReturn.java   
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);
}
项目:infobip-open-jdk-8    文件:T8032704.java   
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;
}
项目:infobip-open-jdk-8    文件:T8032711.java   
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;
}
项目:infobip-open-jdk-8    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:jdk8u-dev-jdk    文件:LambdaReturn.java   
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);
}
项目:jdk8u-dev-jdk    文件:T8032704.java   
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;
}
项目:jdk8u-dev-jdk    文件:T8032711.java   
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;
}
项目:jdk8u-dev-jdk    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:OLD-OpenJDK8    文件:LambdaReturn.java   
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);
}
项目:OLD-OpenJDK8    文件:T8032704.java   
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;
}
项目:OLD-OpenJDK8    文件:T8032711.java   
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;
}
项目:OLD-OpenJDK8    文件:T8032697.java   
private static boolean mf(MethodType mti, MethodType mtf) {
    try {
        LambdaMetafactory.metafactory(l, "m", mti,mtf,h,mtf);
    } catch(LambdaConversionException e) {
        return true;
    }
    return false;
}
项目:BlazeLoader    文件:FuncHandle.java   
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();
}