@ SuppressWarnings ( "unchecked" ) public static < T > Class < ? extends T > loadClass ( String className , Class < T > ofType ) { try { Class < ? > clazz = Class . forName ( className ) ; if ( ofType == null || ! ofType . isAssignableFrom ( clazz ) ) { throw new IllegalArgumentException ( "Class " + className + " must extend or implement " + ofType + "!" ) ; } return ( Class < ? extends T > ) clazz ; } catch ( ClassNotFoundException cnfe ) { throw new IllegalArgumentException ( "Class " + className + " could not be found!" , cnfe ) ; } }
Loads and returns the class named className of type superClass .