I do not understand why I get a warning (unchecked cast) when I try to perform this:
...
Map<? estends SomeType, SomeOtherType> map;
...
Map<SomeType, SomeOtherType> castedMap = (Map<SomeType, SomeOtherType>) map;
...
I mean what is the danger of publishing castedMap to an outside code? Both opperations will work perfectly at runtime:
- getting elements from castedMap using key of type SomeType
- putting elements in castedMap using key of type SomeType.
I would simply suppress warnings using @SuppressWarnings("unchecked").