jakartaee / expression-language

Jakarta Expression Language
https://eclipse.org/ee4j/el
Other
60 stars 49 forks source link

Use custom defined function with prefix #156

Closed Thihup closed 3 years ago

Thihup commented 3 years ago

During some experiments, I've found the following case:

jshell> var elProcessor = new ELProcessor()
elProcessor ==> jakarta.el.ELProcessor@4befd888

jshell> elProcessor.defineFunction("mh", "lookup", "java.lang.invoke.MethodHandles", "lookup")

jshell> elProcessor.eval("mh:lookup()")
$26 ==> com.sun.el.parser.AstFunction

The same happens with Jasper. Is it right to return an AstFunction? If I remove the parenthesis, the parsing fails. From a TCK example, there is the FunctionELResolver, which resolves the only method Int:val (Integer.valueOf).

So it means that the defineFunction using a prefix only works if we add a custom resolver?

markt-asf commented 3 years ago

This is working as intended. MethodHandles.lookup() returns a MethosHandles$Lookup instance. What you are seeing is the result of toString()which returns "com.sun.el.parser.AstFunction"

Custom resolvers play no part in this.