diff options
author | Roland Praml <praml@foconis.de> | 2018-07-09 01:03:47 +0200 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2018-08-20 20:46:31 +0200 |
commit | c157e6537b4d96987879c4ca770f1e1ddf51fe56 (patch) | |
tree | 367d3164db1767406acdc736d12f6c0d30800dad /src/launch/lombok | |
parent | 763b384a169d3303ff82a044ec7be68be92691b1 (diff) | |
download | lombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.tar.gz lombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.tar.bz2 lombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.zip |
Share the same class loader
Diffstat (limited to 'src/launch/lombok')
-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 |
3 files changed, 11 insertions, 5 deletions
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}); |