For map keys, use Method.toString() instead of Method.hashCode()
sbabcoc
released this
05 May 20:34
·
27 commits
to master
since this release
It turns out that the hashCode()
implementation of the java.lang.reflect.Method
class is really weak. It only incorporates the declaring class and the method name, omitting other features of Method objects that make them unique. The implementation uses a non-standard process and isn't a match for the equals()
method of this class. Because the hashcode is so weak, it shouldn't be used as a Map key, but there were several places in JUnit Foundation where it was used for just this purpose.
In this release, I replaced uses of java.lang.reflect.Method#hashCode()
(both explicit and implicit) with the toString()
method.