public static ClassLoader getClassLoader ( final Class < ? > clazz ) { // Context class loader can be null final ClassLoader contextClassLoader = Thread . currentThread ( ) . getContextClassLoader ( ) ; if ( contextClassLoader != null ) { return contextClassLoader ; } if ( clazz != null ) { // The class loader for a specific class can also be null final ClassLoader clazzClassLoader = clazz . getClassLoader ( ) ; if ( clazzClassLoader != null ) { return clazzClassLoader ; } } // The only class loader we can rely on for not being null is the system // one return ClassLoader . getSystemClassLoader ( ) ; }
Gets the class loader .