-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Description
Lior Lipshitz opened SPR-12803 and commented
I'm trying to evaluate the following SpEL expression:
T(com.google.common.collect.Lists).newArrayList(#iterable)
where #iterable is of type java.lang.Iterable. Google Guava com.google.common.collect.Lists (version 14.0) does have a method newArrayList(Iterable) but for some reason SpEL chooses to invoke a different method: newArrayList(Object[])
The issue seems to be with org.springframework.expression.spel.support.ReflectiveMethodResolver implementation: it seems to be sensitive to the manner in which methods are sorted by the java.lang.Class::getMethods. If 2 methods match the invocation (in the case one of the methods is varargs), the later method (in the order) will be invoked, instead of choosing the method that isn't varargs (which is more specific). It seems like JDK doesn't guarantee the order the methods are sorted: different runs yield different order.
Affects: 3.1.1
Reference URL: http://stackoverflow.com/questions/28924430/spring-spel-chooses-wrong-method-to-invoke
Issue Links:
- SpEL: problem with static methods conflicting with instance methods [SPR-12502] #17107 SpEL: problem with static methods conflicting with instance methods
- VerifyError when trying to compile constructor invocation with SpEL [SPR-12326] #16931 VerifyError when trying to compile constructor invocation with SpEL
- SpEL's ReflectiveMethodResolver should use distance computation by default [SPR-12808] #17405 SpEL's ReflectiveMethodResolver should use distance computation by default