This means that the cast will verify that the returned object is a Map
some type, but it will not be able to check anything about its contents due to the erasure of the type. At run time, the map is the map - this is the map ... so if someone put Map<Integer, String>
in your session, this line of code will still succeed. You would get an error only when trying to use one of the entries, for example. by repeating the entries and selecting the key and value.
Welcome to the crazy world of Java generics :(
source share