[fixes #1932] We broke the delombok ant task.

This commit is contained in:
Reinier Zwitserloot committed 2018-11-01 15:01:33 +01:00
1 parent 6e7924f865
commit 21878e253e
6 files changed
+30 -14

No files matched your search

+1 -1
View File
@@ -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)
@@ -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);
}
}
}
+1 -2
View File
@@ -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"));
+2
View File
@@ -0,0 +1,2 @@
/tgt
+10
View File
@@ -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>
@@ -0,0 +1,5 @@
@lombok.Builder @lombok.Value
public class Test {
String hello;
int world;
}