此测试显示了我的问题:
public static String testMe(Predicate filter) {
return "yeah!";
}
@Test
public void testPredicateAsArgument() throws ClassNotFoundException, NoSuchMethodException {
final ELProcessor elp = new ELProcessor();
elp.defineFunction("", "", "test.EL3Test", "testMe");
try {
Object result = elp.eval("testMe(o->true)"); // IllegalArgumentException
// ...
} catch (javax.el.ELException ex) {
fail(Exceptions.getCauseMessage(ex));
}
}
它引发:IllegalArgumentException:无法将类型类javax.el.LambdaExpression的javax.el.LambdaExpression@511baa65转换为接口java.util.function.Predicate
这是EL 3的错误或限制,还是我错过了什么?
测试版本:org.glassfish:javax.el:jar:3.0.0和org.glassfish:javax.el:jar:3.0.1-b08