aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown2
-rw-r--r--src/delombok/lombok/delombok/ant/DelombokTask.java22
-rw-r--r--src/launch/lombok/launch/Main.java3
-rw-r--r--test/manual/delombokAntTask/.gitignore2
-rw-r--r--test/manual/delombokAntTask/build.xml10
-rw-r--r--test/manual/delombokAntTask/src/Test.java5
6 files changed, 30 insertions, 14 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 6a42bf70..57112d76 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -2,7 +2,7 @@ Lombok Changelog
----------------
### v1.18.5 "Edgy Guinea Pig"
-* Edge currently has no new features.
+* BUGFIX: Since version 1.18.4, the delombok ant task didn't work and errored with a `NoClassDefFoundError`. [Issue #1932](https://github.com/rzwitserloot/lombok/issues/1932)
### v1.18.4 (October 30th, 2018)
* PLATFORM: Support for Eclipse Photon. [Issue #1831](https://github.com/rzwitserloot/lombok/issues/1831)
diff --git a/src/delombok/lombok/delombok/ant/DelombokTask.java b/src/delombok/lombok/delombok/ant/DelombokTask.java
index 3828a5db..e09b8ed2 100644
--- a/src/delombok/lombok/delombok/ant/DelombokTask.java
+++ b/src/delombok/lombok/delombok/ant/DelombokTask.java
@@ -29,9 +29,6 @@ import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;
-import lombok.Lombok;
-import lombok.permit.Permit;
-
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Task;
@@ -177,14 +174,16 @@ class Tasks {
} catch (ClassNotFoundException e) {
// If we get here, it isn't, and we should use the shadowloader.
Class<?> launcherMain = Class.forName("lombok.launch.Main");
- Method m = Permit.getMethod(launcherMain, "createShadowClassLoader");
+ Method m = launcherMain.getDeclaredMethod("getShadowClassLoader");
+ m.setAccessible(true);
shadowLoader = (ClassLoader) m.invoke(null);
}
}
return Class.forName(name, true, shadowLoader);
} catch (Exception e) {
- throw Lombok.sneakyThrow(e);
+ if (e instanceof RuntimeException) throw (RuntimeException) e;
+ throw new RuntimeException(e);
}
}
@@ -195,9 +194,9 @@ class Tasks {
try {
Object instance = shadowLoadClass("lombok.delombok.ant.DelombokTaskImpl").newInstance();
for (Field selfField : getClass().getDeclaredFields()) {
- Permit.setAccessible(selfField);
if (selfField.isSynthetic() || Modifier.isStatic(selfField.getModifiers())) continue;
- Field otherField = Permit.getField(instance.getClass(), selfField.getName());
+ Field otherField = instance.getClass().getDeclaredField(selfField.getName());
+ otherField.setAccessible(true);
if (selfField.getName().equals("formatOptions")) {
List<String> rep = new ArrayList<String>();
for (Format f : formatOptions) {
@@ -210,12 +209,13 @@ class Tasks {
}
}
- Method m = Permit.getMethod(instance.getClass(), "execute", Location.class);
+ Method m = instance.getClass().getMethod("execute", Location.class);
m.invoke(instance, loc);
- } catch (InvocationTargetException e) {
- throw Lombok.sneakyThrow(e.getCause());
} catch (Exception e) {
- throw Lombok.sneakyThrow(e);
+ Throwable t = (e instanceof InvocationTargetException) ? ((InvocationTargetException) e).getCause() : e;
+ if (t instanceof Error) throw (Error) t;
+ if (t instanceof RuntimeException) throw (RuntimeException) t;
+ throw new RuntimeException(t);
}
}
}
diff --git a/src/launch/lombok/launch/Main.java b/src/launch/lombok/launch/Main.java
index 82913f8e..08298cc2 100644
--- a/src/launch/lombok/launch/Main.java
+++ b/src/launch/lombok/launch/Main.java
@@ -25,9 +25,8 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
class Main {
-
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"));
diff --git a/test/manual/delombokAntTask/.gitignore b/test/manual/delombokAntTask/.gitignore
new file mode 100644
index 00000000..7b85d899
--- /dev/null
+++ b/test/manual/delombokAntTask/.gitignore
@@ -0,0 +1,2 @@
+/tgt
+
diff --git a/test/manual/delombokAntTask/build.xml b/test/manual/delombokAntTask/build.xml
new file mode 100644
index 00000000..d3f5e4cf
--- /dev/null
+++ b/test/manual/delombokAntTask/build.xml
@@ -0,0 +1,10 @@
+<project name="delombokAntTest" default="delombok">
+ <target name="delombok">
+ <taskdef classname="lombok.delombok.ant.Tasks$Delombok" classpath="../../../dist/lombok.jar" name="delombok" />
+ <mkdir dir="tgt" />
+ <delombok verbose="true" encoding="UTF-8" to="tgt" from="src">
+ <format value="suppressWarnings:skip" />
+ </delombok>
+ </target>
+</project>
+
diff --git a/test/manual/delombokAntTask/src/Test.java b/test/manual/delombokAntTask/src/Test.java
new file mode 100644
index 00000000..e3a8bc75
--- /dev/null
+++ b/test/manual/delombokAntTask/src/Test.java
@@ -0,0 +1,5 @@
+@lombok.Builder @lombok.Value
+public class Test {
+ String hello;
+ int world;
+}