While debugging bizarre issues with persistent auto-timers, I discovered that the EJB component uses java.lang.reflect.Method as a key in an IdentityHashMap. Like every AccessibleObject, a Method is inherently mutable. For this reason, Method overrides Object.hashCode() and methods such as Class.getMethods(...), getDeclaredMethods(...), etc. will always return a new Method instance. In general, unless one can guarantee that all calls to IdentityHashMap.get(...) will use the same Method instance used to create the map entry, a Method should not be used as a key in an IdentityHashMap, especially if the contents of this map can be accessed publicly.
-
Paul Ferraro
-
Paul Ferraro
- Votes:
-
0 Vote for this issue
- Watchers:
-
3 Start watching this issue
- Created:
- Updated: