Generics type is about the erasure and cast, so if you mix use the generic and non-generic will compile but will throw RuntimeException.
Rule: generic is compiler magic,it simply erase the type and cast it.
Look at the source code I decompiled from the TestMap:
You see? it Cast the Integer to
String, that's why throw ClassCastException.
Best,
Yue