public static Class < ? > loadClass ( String name , ClassLoader callerClassLoader ) throws ClassNotFoundException { Class < ? > clazz = null ; try { ClassLoader loader = getContextClassLoader ( ) ; if ( loader != null ) { clazz = loader . loadClass ( name ) ; } } catch ( ClassNotFoundException e ) { // treat as though loader not set } if ( clazz == null ) { if ( callerClassLoader != null ) { clazz = callerClassLoader . loadClass ( name ) ; } else { clazz = Class . forName ( name ) ; } } return clazz ; }
Loads the class with the specified name . For Java 2 callers the current thread s context class loader is preferred falling back on the class loader of the caller when the current thread s context is not set or the caller is pre Java 2 . If the callerClassLoader is null then fall back on the system class loader .