Consider the following clause of JLS8:ยง5.5.2
A cast from a type
S
to a type variableT
is unchecked unlessS <: T
.
Here is how I tried to implement the understanding around the scenario that JLS tries to discuss:
class Scratch {
public static <T extends Number> void hitMe(T a){
T aa = (T) new Integer(34); //unchecked cast warning
}
}
But still I see the compile time warning regarding the unchecked casts in play. What is the scenario that JLS is trying to point to here?