Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Cannot Reproduce
-
1.7
-
None
-
None
Description
I try to add a java.util.Map instance to Velocity context and access its values from a template, for example: ${map.get("someKey")}
It doesn't work if use my own implementation of Map.get(Object key). It doesn't matter whether I implement Map from scratch, or subclass HashMap and override the get(Object key) metho. The get method is never called and the engine output is: ${map.get("someKey")}.
It does work if I use my own subclass of HashMap without overriding the get(Object key) method.
It does work if I use my own implementation of Map with the get(String key) method added: the get(String key) is called instead of get(Object key).
It does work if I use my class that doesn't implement Map, but has a get(Object key) method.
More discussion of this on Velocity-User mailing list: http://old.nabble.com/Can%27t-acces-map-values-when-get%28%29-is-overriden-td31955214.html