These classes are really necessary if you are abusing (or not using) generics. It duplicates when checking the runtime, which should be sufficient to run at compile time with security guarantees like the generic mechanism.
As a result, the use of these methods is really interesting in the context of API designers who do not trust library users and want to protect themselves or users from users who use the card improperly.
In this case: if your code compiles without warnings about the raw type or any unverified warnings about the conversion / type, you are guaranteed that the checked* methods do not do you any good; they only crash at runtime.
Edit
You seem to conclude that since remove , get , etc. work on Object , they are somehow unsafe. They are not. None of these methods will save their operand on the card, so you certainly will not compromise security like the card itself. These methods accept an object for one main reason: for backward compatibility. There have never been any stringent requirements that would be required to adhere to the same class. For example, if an instance of class A and an instance of class B can be somehow equal to each other, put a on the card, and then calling remove(b) should remove the mapping a .
This behavior needed to be maintained after adding generics to maintain backward compatibility. Thus, they were not able to upgrade the interface to something like remove(K) , because existing code can rely on the ability to remove a mapping based on an instance of a completely different class. However, it is not safe, and using a verified version of the card does not alter this behavior in the least.
Mark peters
source share