Because you're mixing generic and non-generic code.
The compiler lets you do it because when generics were introduced they were designed to be backwards compatible. So it will let you add the non-generic Map to the generic one. I would expect you to see a warning, but it won't actually stop you.
At run-time it works because of type-erasure - the generic information doesn't exist at run-time. You'd only get an exception if you tried to extract the key and assign it to a String - then you'd get a ClassCastException.
The bottom line is - don't do it. Always use generics, unless you are forced to work with existing classes that don't.
Joined: May 14, 2010
Thanks for the info and for clearing my doubts Matthew.