Bug 56636 - EL defineFunction method signature parser fails to correctly match signatures to methods
EL defineFunction method signature parser fails to correctly match signatures...
Status: RESOLVED FIXED
Product: Tomcat 8
Classification: Unclassified
Component: EL
8.0.x-trunk
PC All
: P2 normal (vote)
: ----
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2014-06-17 19:25 UTC by Arthur Fiedler
Modified: 2014-06-18 10:35 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Arthur Fiedler 2014-06-17 19:25:28 UTC
Per the javadoc at http://docs.oracle.com/javaee/7/api/javax/el/ELProcessor.html it specifies that defineFunction(String prefix, String function, String className, String method) should support method names (without parenthesis) and method signatures, it gives an example of "int sum(int, int)"

The code I was using from 8.0.8 does not properly parse this example, in the javax.el.ElProcessor.MethodSignature class the constructor first incorrectly cuts off the last character of the method name by using "methodName.substring(0, paramIndex -1)" second it continues to include the return type in the name.

A better but not to java specification version would be to replace the following code

int paramIndex = methodName.indexOf('(');

if (paramIndex == -1) {
    name = methodName.trim();
    parameterTypeNames = null;
} else {
    name = methodName.substring(0, paramIndex -1).trim();


with:

int paramIndex = methodName.indexOf('(');

if (paramIndex == -1) {
    name = methodName.trim();
    parameterTypeNames = null;
} else {
    String tmpName = methodName.substring(0, paramIndex).trim();
    int lastWhitespaceIndex = tmpName.lastIndexOf(' ');
    name = lastWhitespaceIndex > -1 ? tmpName.substring(lastWhitespaceIndex + 1) : tmpName;


This allows the MethodSignature class to return a proper method name that then can be used in the ELProcessor.defineFunction method to compare the reflected classes method names.
Comment 1 Mark Thomas 2014-06-18 10:35:49 UTC
Thanks for the report. This has been fixed in 8.0.x and will be included in 8.0.9 onwards.