diff --git a/pom.xml b/pom.xml index 56944d6..111df13 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ net.azisaba Log4j2Fix - 1.0.0 + 1.0.1 8 diff --git a/src/main/java/net/azisaba/log4j2Fix/Log4j2Fix.java b/src/main/java/net/azisaba/log4j2Fix/Log4j2Fix.java index 89f556d..fb94847 100644 --- a/src/main/java/net/azisaba/log4j2Fix/Log4j2Fix.java +++ b/src/main/java/net/azisaba/log4j2Fix/Log4j2Fix.java @@ -10,8 +10,6 @@ import java.io.InputStreamReader; import java.lang.instrument.Instrumentation; import java.lang.reflect.Method; -import java.net.URL; -import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -28,9 +26,9 @@ public static void main(String[] args) throws IOException { } String main = arguments.remove(0); File file = new File(main); - ClassLoader classLoader; if (file.exists()) { - classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()}, Log4j2Fix.class.getClassLoader()); + System.out.println("Using " + file.getAbsolutePath() + " for classpath"); + NativeUtil.appendToSystemClassLoaderSearch(file.getAbsolutePath()); ZipFile zipFile = new ZipFile(file); ZipEntry zipEntry = zipFile.getEntry("META-INF/MANIFEST.MF"); if (zipEntry == null) { @@ -59,11 +57,9 @@ public static void main(String[] args) throws IOException { main = arguments.remove(0); } } - } else { - classLoader = Log4j2Fix.class.getClassLoader(); } try { - Class clazz = Class.forName(main, false, classLoader); + Class clazz = Class.forName(main); Method m = clazz.getMethod("main", String[].class); m.invoke(null, (Object) arguments.toArray(new String[0])); } catch (ReflectiveOperationException e) {