1010import java .io .InputStreamReader ;
1111import java .lang .instrument .Instrumentation ;
1212import java .lang .reflect .Method ;
13- import java .net .URL ;
14- import java .net .URLClassLoader ;
1513import java .util .ArrayList ;
1614import java .util .Arrays ;
1715import java .util .List ;
@@ -28,9 +26,9 @@ public static void main(String[] args) throws IOException {
2826 }
2927 String main = arguments .remove (0 );
3028 File file = new File (main );
31- ClassLoader classLoader ;
3229 if (file .exists ()) {
33- classLoader = new URLClassLoader (new URL []{file .toURI ().toURL ()}, Log4j2Fix .class .getClassLoader ());
30+ System .out .println ("Using " + file .getAbsolutePath () + " for classpath" );
31+ NativeUtil .appendToSystemClassLoaderSearch (file .getAbsolutePath ());
3432 ZipFile zipFile = new ZipFile (file );
3533 ZipEntry zipEntry = zipFile .getEntry ("META-INF/MANIFEST.MF" );
3634 if (zipEntry == null ) {
@@ -59,11 +57,9 @@ public static void main(String[] args) throws IOException {
5957 main = arguments .remove (0 );
6058 }
6159 }
62- } else {
63- classLoader = Log4j2Fix .class .getClassLoader ();
6460 }
6561 try {
66- Class <?> clazz = Class .forName (main , false , classLoader );
62+ Class <?> clazz = Class .forName (main );
6763 Method m = clazz .getMethod ("main" , String [].class );
6864 m .invoke (null , (Object ) arguments .toArray (new String [0 ]));
6965 } catch (ReflectiveOperationException e ) {
0 commit comments