diff options
author | Roel Spilker <r.spilker@gmail.com> | 2016-11-07 23:26:39 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2016-11-07 23:26:39 +0100 |
commit | 192c569128d1ffb879fb104f44483e394032a790 (patch) | |
tree | 28e3d27ac0105cae0638998c3b086e83b7539da8 /src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | |
parent | 49f0bc1c3ede3c81754568af22fcdbbe8f4b5a8f (diff) | |
download | lombok-192c569128d1ffb879fb104f44483e394032a790.tar.gz lombok-192c569128d1ffb879fb104f44483e394032a790.tar.bz2 lombok-192c569128d1ffb879fb104f44483e394032a790.zip |
[issue #1218] Annotation Processors that have an (internal) dependency on ecj (google's dagger project has this, don't know of any others), when run inside eclipse, bombs with a LinkageError. Fixed.
Diffstat (limited to 'src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java')
-rw-r--r-- | src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java index 7c538b6f..4b18dc0f 100644 --- a/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java +++ b/src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java @@ -24,11 +24,14 @@ package lombok.eclipse.agent; import static lombok.patcher.scripts.ScriptBuilder.*; import java.lang.instrument.Instrumentation; +import java.net.URLClassLoader; +import java.security.ProtectionDomain; import java.util.Collection; import java.util.Collections; import java.util.List; import lombok.core.AgentLauncher; +import lombok.patcher.Filter; import lombok.patcher.Hook; import lombok.patcher.MethodTarget; import lombok.patcher.ScriptManager; @@ -74,6 +77,15 @@ public class EclipsePatcher implements AgentLauncher.AgentLaunchable { private static void registerPatchScripts(Instrumentation instrumentation, boolean reloadExistingClasses, boolean ecjOnly, Class<?> launchingContext) { ScriptManager sm = new ScriptManager(); sm.registerTransformer(instrumentation); + sm.setFilter(new Filter() { + @Override public boolean shouldTransform(ClassLoader loader, String className, Class<?> classBeingDefined, ProtectionDomain protectionDomain, byte[] classfileBuffer) { + if (!(loader instanceof URLClassLoader)) return true; + ClassLoader parent = loader.getParent(); + if (parent == null) return true; + return !parent.getClass().getName().startsWith("org.eclipse.jdt.apt.core.internal.AnnotationProcessorFactoryLoader"); + } + }); + final boolean forceBaseResourceNames = !"".equals(System.getProperty("shadow.override.lombok", "")); sm.setTransplantMapper(new TransplantMapper() { public String mapResourceName(int classFileFormatVersion, String resourceName) { |