aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoland Praml <praml@foconis.de>2018-07-09 01:03:47 +0200
committerRoel Spilker <r.spilker@gmail.com>2018-08-20 20:46:31 +0200
commitc157e6537b4d96987879c4ca770f1e1ddf51fe56 (patch)
tree367d3164db1767406acdc736d12f6c0d30800dad /src
parent763b384a169d3303ff82a044ec7be68be92691b1 (diff)
downloadlombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.tar.gz
lombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.tar.bz2
lombok-c157e6537b4d96987879c4ca770f1e1ddf51fe56.zip
Share the same class loader
Diffstat (limited to 'src')
-rw-r--r--src/eclipseAgent/lombok/launch/PatchFixesHider.java2
-rw-r--r--src/launch/lombok/launch/Agent.java2
-rw-r--r--src/launch/lombok/launch/AnnotationProcessor.java2
-rw-r--r--src/launch/lombok/launch/Main.java12
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});