Closed glassfishrobot closed 4 years ago
@glassfishrobot Commented Reported by cbauer123
@glassfishrobot Commented cbauer123 said: The root cause is probably that AstMethodArguments#getParamTypes() doesn't seem to be implemented. If overloaded methods are not supported at all, or until this is implemented, an UnsupportedOperationException should be thrown if a class has several methods with the same name and parameter count.
@glassfishrobot Commented This issue was imported from java.net JIRA UEL-35
Reviewing the code that was imported into Jakarta Expression Language, this issue is resolved. The findMethod()
methods use a much more comprehensive search algorithm that includes a careful match of parameter types, including allowing for coercion.
The code in ELUtil#findMethod() is broken, it depends on the order of elements of Class#getMethods():
The first method returned by Class#getMethods() with a matching name and parameter count will be used, someone ignored that "The elements in the array returned are not sorted and are not in any particular order."
This leads to seemingly random exceptions if you have overloaded methods:
Sometimes the bar(String) method will be picked, sometimes the bar(int) method.
Environment
javax.el-3.0-b07.jar