Hi,

I am using Spring expression language (5.3.15).

I found the following method does sorting on a list of methods (ReflectiveMethodResolver).

public MethodExecutor resolve(EvaluationContext context, Object targetObject, String name,
            List<TypeDescriptor> argumentTypes) throws AccessException 

I did some benchmarking and found it cost me at least 100 milliseconds more.

Is it possible to make this sorting optional ?

I am attaching the benchmark logs with and without sorting .

Do we really need the following code ?

            // Sort methods into a sensible order
    /*      if (methods.size() > 1) {
                methods.sort((m1, m2) -> {
                     if(m1==null ||m2==null)
                     {

                         System.out.println("==================Some method came null  ");
                     }
                    int m1pl = m1.getParameterCount();
                    int m2pl = m2.getParameterCount();
                    // vararg methods go last
                    if (m1pl == m2pl) {
                        if (!m1.isVarArgs() && m2.isVarArgs()) {
                            return -1;
                        }
                        else if (m1.isVarArgs() && !m2.isVarArgs()) {
                            return 1;
                        }
                        else {
                            return 0;
                        }
                    }
                    return Integer.compare(m1pl, m2pl);
                });
            }*/

Thanks,

Aashish

translator-without-sorting.log translatorwith-sorting-.log

Comment From: aashishtyagi

Hi,

Are we planning to remove this sorting code in some future release?

Thanks, Aashish

Comment From: jhoeller

While the sorting is necessary for properly differentiating between overloaded methods, it turns out that we match the methods by name too late there: We can easily filter for a name match first and only then sort and traverse.