private static ClassLoader createClassLoader ( File toolsJar ) throws MalformedURLException { final URL urls [ ] = new URL [ ] { toolsJar . toURI ( ) . toURL ( ) } ; if ( System . getSecurityManager ( ) == null ) { return new URLClassLoader ( urls , getParentClassLoader ( ) ) ; } else { return AccessController . doPrivileged ( new PrivilegedAction < ClassLoader > ( ) { /** {@inheritDoc} */ public ClassLoader run ( ) { return new URLClassLoader ( urls , getParentClassLoader ( ) ) ; } } ) ; } }
Create a classloader and respect a security manager if installed