I am trying to evaluate the following SpEL expression (Spring -expression version 3.1.1):
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) has a newArrayList (Iterable) method, but for some reason SpEL selects a call to another method: newArrayList (Object [])
I plunged into the code and found that the problem was with the implementation of org.springframework.expression.spel.support.ReflectiveMethodResolver : it seems to be sensitive to how methods are sorted by java.lang.Class :: GetMethods. If 2 methods correspond to the call (in the case when one of the methods is varargs), a later method will be called (in order) instead of choosing a method that is not varargs (more specifically). The JDK does not seem to guarantee the sort order of the methods: different traces show a different order.
Is there any way to overcome this problem?
source
share