@SuppressWarnings({"unchecked"})
public <U> Class<? extends U> asSubclass (Class<U> clazz)

Casts this Class object to represent a subclass of the class represented by the specified class object. Checks that the cast is valid, and throws a ClassCastException if it is not. If this method succeeds, it always returns a reference to this class object.

This method is useful when a client needs to "narrow" the type of a Class object to pass it to an API that restricts the Class objects that it is willing to accept. A cast would generate a compile-time warning, as the correctness of the cast could not be checked at runtime (because generic types are implemented by erasure).

Parameters:
<U>    the type to cast this class object to
clazz    the class of the type to cast this class object to

Returns:  this Class object, cast to represent a subclass of the specified class object.

Exceptions:
ClassCastException    if this Class object does not represent a subclass of the specified class (here "subclass" includes the class itself).

Since:  1.5