From 192c569128d1ffb879fb104f44483e394032a790 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 7 Nov 2016 23:26:39 +0100 Subject: [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. --- .../ivy-repo/org.projectlombok-lombok.patcher-0.20.xml | 14 -------------- .../ivy-repo/org.projectlombok-lombok.patcher-0.22.xml | 14 ++++++++++++++ buildScripts/ivy.xml | 2 +- doc/changelog.markdown | 1 + src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java | 12 ++++++++++++ 5 files changed, 28 insertions(+), 15 deletions(-) delete mode 100644 buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.20.xml create mode 100644 buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.22.xml diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.20.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.20.xml deleted file mode 100644 index f8ddcb51..00000000 --- a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.20.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff --git a/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.22.xml b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.22.xml new file mode 100644 index 00000000..85e2f9ef --- /dev/null +++ b/buildScripts/ivy-repo/org.projectlombok-lombok.patcher-0.22.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml index e0066ae4..3a851fcd 100644 --- a/buildScripts/ivy.xml +++ b/buildScripts/ivy.xml @@ -15,7 +15,7 @@ - + diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 89df8709..474ca2f5 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -3,6 +3,7 @@ Lombok Changelog ### v1.16.11 "Edgy Guinea Pig" * v1.16.10 is the latest release +* BUGFIX: Annotation Processors that use ecj internally (dagger) no longer give linkage errors [Issue #1218](https://github.com/rzwitserloot/lombok/issues/1218) * BUGFIX: `val` in lambda expressions now work as expected [Issue #911](https://github.com/rzwitserloot/lombok/issues/911) * PLATFORM: Red Hat JBoss Developer Studio is now correctly identified by the installer [Issue #1164](https://github.com/rzwitserloot/lombok/issues/1164) * BUGFIX: delombok: for-loops with initializers that are not local variables would be generated incorrectly [Issue #1076](https://github.com/rzwitserloot/lombok/issues/1076) 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) { -- cgit