https://issues.apache.org/bugzilla/show_bug.cgi?id=56636
Bug ID: 56636
Summary: EL defineFunction method signature parser fails to
correctly match signatures to methods
Product: Tomcat 8
Version: trunk
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: EL
Assignee: [email protected]
Reporter: [email protected]
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.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]