>> == >> Map<String, Object> context: >> >> This means that the type of the values stored in the context need to >> be of type Object. Since all objects are this way, anything can be >> stored into the context. >> >> Map<String, ? extends Object> context: >> >> This means that the *concrete* type of the value is *some unknown* >> class, that extends Object. Anyone can pull anything out of this >> context, as it *will* extend Object. However, since the actual type >> of the values is not known, no one can put anything in, as it might >> cause a ClassCastException somewhere. >> >> == >> >> The former can be cast to the latter, but not vice versa. >> >> Plus, it's rather good form, to consider *all* incoming parameters on >> *any* method(not just service implementations) to be read-only, and >> only return results thru the method's return value. This is called >> having no side-effects. >> >> Also look at this: >> http://www.angelikalanger.com/GenericsFAQ/JavaGenericsFAQ.html > > Ah okay I see, so using Object doesn't modify the context but it does > allow the context to be modified whereas ? will block any attempts to > use put. > > BTW, <String, ? extends Object> is the same as using <String, ?> isn't it?
No. ? means you have no idea what kind of value is in the map. None at all. All you can do with such a map is take it's size, work with the keyset, or remove values. You can't store values, can't do anything with values *returned* from methods. I't s a pure side-effect that all classes in java extend Object, but the generics markup above doesn't consider that.
