Static Public Member Functions | |
static< T > T | unchecked_cast (Object x) |
The Java runtime, in its infinite wisdom, decided to introduce a typechecking mechanism into Java 1.5 and higher. |
static <T> T edu.cmu.hcii.calo.util.Utility.unchecked_cast | ( | Object | x | ) | [static] |
The Java runtime, in its infinite wisdom, decided to introduce a typechecking mechanism into Java 1.5 and higher.
This is usually great, but in many cases it's impossible to satisfy the typechecker while using features introduces in earlier versions of Java, like the clone() method (which returns Object, and makes you cast to the right thing after the fact). You can suppress typechecking warnings, but only on a per-method scope, which is bad if you actually do have a type violation somewhere else in the same method. This method, therefore, restricts the scope of the unchecked code to only an individual cast.
x | the thing you want to cast |