EsotericSoftware / reflectasm

High performance Java reflection
BSD 3-Clause "New" or "Revised" License
1.53k stars 222 forks source link

MethodAccess.getIndex lookup of incorrect method definition index #55

Closed pranasblk closed 7 years ago

pranasblk commented 7 years ago

There are 2 methods:

Actual result: MethodAccess.getIndex("getStrategyName") picks up the incorrect one.

Expected result: Index of second definition must be retrieved if no parameters specified.

pranasblk commented 7 years ago

Current work around: access.getIndex(getterName, new Class[] {})

and fall back to (for more similar potential issus): final Method reflect = clazz.getDeclaredMethod(getterName); return reflect.invoke(e);

NathanSweet commented 7 years ago

Per the javadocs, getIndex(String) "Returns the index of the first method with the specified name." You need to specify the parameters if your method has multiple names. It may be nice to sort the methods by number of arguments, please feel free to make a PR if you'd like that.