private boolean useExistingClassLoader() {
    if (!forceNewClassLoader && parentLoader instanceof UDFClassLoader) {
      final UDFClassLoader udfClassLoader = (UDFClassLoader) parentLoader;
      // The classloader may have been closed, Cannot add to the same instance
      return !udfClassLoader.isClosed();
    }
    // Cannot use the same classloader if it is not an instance of {@code UDFClassLoader}, or new loader was explicitly
    // requested
    return false;
  }
Helper class to create UDFClassLoader when running under a security manager. To create a class loader:
&gt; AddToClassPathAction addAction = new AddToClassPathAction(parentLoader, newPaths, true);
&gt; UDFClassLoader childClassLoader = AccessController.doPrivileged(addAction);
To try to add to the class path of the existing class loader; call the above without forceNewClassLoader=true.
Note that a class loader might be still created as fallback method.
<p>
This is slightly inconvenient, but forces the caller code to make the doPrivileged call, rather than us making the
call on the caller's behalf, in accordance with the security guidelines at:
https://docs.oracle.com/javase/8/docs/technotes/guides/security/doprivileged.html
ql/src/java/org/apache/hadoop/hive/ql/exec/AddToClassPathAction.java