code: private static void setContextClassLoader(final Class<?> clazz) {
          AccessController.doPrivileged(new PrivilegedAction<Void>() {
              @Override
              public Void run() {
                  Thread.currentThread().setContextClassLoader(clazz.getClassLoader());
                  return null;
              }
          });
      }
docs: Convenience method to set the context ClassLoader for the current thread
  using {@link AccessController#doPrivileged(PrivilegedAction)}.
  
  @param clazz The class to get the {@link ClassLoader} to set when calling.
  {@link Thread#currentThread()#setContextClassLoader(ClassLoader)}.