diff options
-rw-r--r-- | src/eclipseAgent/lombok/launch/PatchFixesHider.java | 2 | ||||
-rw-r--r-- | src/launch/lombok/launch/Agent.java | 2 | ||||
-rw-r--r-- | src/launch/lombok/launch/AnnotationProcessor.java | 2 | ||||
-rw-r--r-- | src/launch/lombok/launch/Main.java | 12 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java index 317b06a4..3c70d81d 100644 --- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java +++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java @@ -92,7 +92,7 @@ final class PatchFixesHider { shadowLoader = Util.class.getClassLoader(); } catch (ClassNotFoundException e) { // If we get here, it isn't, and we should use the shadowloader. - shadowLoader = Main.createShadowClassLoader(); + shadowLoader = Main.getShadowClassLoader(); } } diff --git a/src/launch/lombok/launch/Agent.java b/src/launch/lombok/launch/Agent.java index 7989e51f..357a8e48 100644 --- a/src/launch/lombok/launch/Agent.java +++ b/src/launch/lombok/launch/Agent.java @@ -35,7 +35,7 @@ final class Agent { } private static void runLauncher(String agentArgs, Instrumentation instrumentation, boolean injected) throws Throwable { - ClassLoader cl = Main.createShadowClassLoader(); + ClassLoader cl = Main.getShadowClassLoader(); try { Class<?> c = cl.loadClass("lombok.core.AgentLauncher"); Method m = c.getDeclaredMethod("runAgents", String.class, Instrumentation.class, boolean.class, Class.class); diff --git a/src/launch/lombok/launch/AnnotationProcessor.java b/src/launch/lombok/launch/AnnotationProcessor.java index c4f922b9..b03dec76 100644 --- a/src/launch/lombok/launch/AnnotationProcessor.java +++ b/src/launch/lombok/launch/AnnotationProcessor.java @@ -104,7 +104,7 @@ class AnnotationProcessorHider { } private static AbstractProcessor createWrappedInstance() { - ClassLoader cl = Main.createShadowClassLoader(); + ClassLoader cl = Main.getShadowClassLoader(); try { Class<?> mc = cl.loadClass("lombok.core.AnnotationProcessor"); return (AbstractProcessor) mc.getDeclaredConstructor().newInstance(); diff --git a/src/launch/lombok/launch/Main.java b/src/launch/lombok/launch/Main.java index b81b6268..82913f8e 100644 --- a/src/launch/lombok/launch/Main.java +++ b/src/launch/lombok/launch/Main.java @@ -25,12 +25,18 @@ import java.lang.reflect.InvocationTargetException; import java.util.Arrays; class Main { - static ClassLoader createShadowClassLoader() { - return new ShadowClassLoader(Main.class.getClassLoader(), "lombok", null, Arrays.<String>asList(), Arrays.asList("lombok.patcher.Symbols")); + + private static ShadowClassLoader classLoader; + + static synchronized ClassLoader getShadowClassLoader() { + if (classLoader == null) { + classLoader = new ShadowClassLoader(Main.class.getClassLoader(), "lombok", null, Arrays.<String>asList(), Arrays.asList("lombok.patcher.Symbols")); + } + return classLoader; } public static void main(String[] args) throws Throwable { - ClassLoader cl = createShadowClassLoader(); + ClassLoader cl = getShadowClassLoader(); Class<?> mc = cl.loadClass("lombok.core.Main"); try { mc.getMethod("main", String[].class).invoke(null, new Object[] {args}); |