public static ClassLoader getAndSetLoader ( ClassLoader newCL ) { ThreadContextAccessor tca = ThreadContextAccessor . getThreadContextAccessor ( ) ; //This could be a ClassLoader or the special type UNCHANGED. Object maybeOldCL = tca . pushContextClassLoaderForUnprivileged ( newCL ) ; if ( maybeOldCL instanceof ClassLoader ) { return ( ClassLoader ) maybeOldCL ; } else { return newCL ; } }
This method sets the thread context classloader and returns whatever was the TCCL before it was updated .