aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown4
-rw-r--r--src/core/lombok/core/handlers/HandlerUtil.java2
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java2
-rwxr-xr-xsrc/delombok/lombok/delombok/Delombok.java5
-rw-r--r--src/delombok/lombok/delombok/DelombokApp.java2
-rw-r--r--src/delombok/lombok/delombok/ant/DelombokTaskImpl.java5
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java5
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java77
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java39
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java70
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java32
-rw-r--r--test/transform/resource/before/SuperBuilderSingularCustomized.java9
-rw-r--r--test/transform/resource/before/SuperBuilderWithExistingConstructor.java5
14 files changed, 243 insertions, 16 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 6954c6ea..64bad8ba 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -4,7 +4,9 @@ Lombok Changelog
### v1.18.19 "Edgy Guinea Pig"
* PLATFORM: JDK16 support added. [Issue #2681](https://github.com/mplushnikov/lombok-intellij-plugin/issues/2681).
* BUGFIX: Trying to use a lambda expression as parameter to an `@ExtensionMethod` did not work. [Issue #2741](https://github.com/rzwitserloot/lombok/issues/2741). (by __@Rawi01__).
-* POTENTIAL BUGFIX: lombok + errorprone could cause `IllegalArgumentException` if using the `MissingSummay` bug pattern. [Issue #2730](https://github.com/rzwitserloot/lombok/issues/2612).
+* BUGFIX: `@SuperBuilder` with an existing constructor caused issues in eclipse. [Issue #2704](https://github.com/rzwitserloot/lombok/issues/2704). (by [@JanRieke](https://github.com/rzwitserloot/lombok/pull/2770)).
+* BUGFIX: Using `@SuperBuilder` with a handwritten builder class caused issues. [Issue #2701](https://github.com/rzwitserloot/lombok/issues/2701). (by [@JanRieke](https://github.com/rzwitserloot/lombok/pull/2772)).
+* POTENTIAL BUGFIX: lombok + errorprone could cause `IllegalArgumentException` if using the `MissingSummary` bug pattern. [Issue #2730](https://github.com/rzwitserloot/lombok/issues/2730).
### v1.18.18 (January 28th, 2021)
* BUGFIX: Various tools using ecj under the hood (including intellij) could cause corrupt class files to be generated. [PR #2637](https://github.com/rzwitserloot/lombok/pull/2637), [lombok-intellij-plugin issue #969](https://github.com/mplushnikov/lombok-intellij-plugin/issues/969).
diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java
index 14c2d66c..19cc5a9e 100644
--- a/src/core/lombok/core/handlers/HandlerUtil.java
+++ b/src/core/lombok/core/handlers/HandlerUtil.java
@@ -325,7 +325,9 @@ public class HandlerUtil {
"com.fasterxml.jackson.annotation.JsonTypeInfo",
"com.fasterxml.jackson.annotation.JsonView",
"com.fasterxml.jackson.databind.annotation.JsonDeserialize",
+ "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper",
"com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty",
+ "com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText",
}));
COPY_TO_BUILDER_SINGULAR_SETTER_ANNOTATIONS = Collections.unmodifiableList(Arrays.asList(new String[] {
"com.fasterxml.jackson.annotation.JsonAnySetter",
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 3686cb03..3599dbe0 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -1204,7 +1204,7 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
if (!def.isConstructor()) continue;
if (isTolerate(type, def)) continue;
- if (def.arguments.length != 1) continue;
+ if (def.arguments == null || def.arguments.length != 1) continue;
// Cannot use typeMatches() here, because the parameter could be fully-qualified, partially-qualified, or not qualified.
// A string-compare of the last part should work. If it's a false-positive, users could still @Tolerate it.
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index a083adb9..17b54f3c 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -302,7 +302,7 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
if (sd == null) continue;
JavacSingularizer singularizer = sd.getSingularizer();
if (singularizer == null) continue;
- if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderType, sd)) {
+ if (singularizer.checkForAlreadyExistingNodesAndGenerateError(job.builderAbstractType, sd)) {
bfd.singularData = null;
}
}
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index b210bab9..10ec5015 100755
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -168,6 +168,10 @@ public class Delombok {
private boolean help;
}
+ static {
+ LombokProcessor.addOpensForLombok();
+ }
+
private static String indentAndWordbreak(String in, int indent, int maxLen) {
StringBuilder out = new StringBuilder();
StringBuilder line = new StringBuilder();
@@ -315,7 +319,6 @@ public class Delombok {
}
}
- LombokProcessor.addOpensForLombok();
delombok.delombok();
} catch (Exception e) {
if (!args.quiet) {
diff --git a/src/delombok/lombok/delombok/DelombokApp.java b/src/delombok/lombok/delombok/DelombokApp.java
index ef3bbd50..f5a5fc81 100644
--- a/src/delombok/lombok/delombok/DelombokApp.java
+++ b/src/delombok/lombok/delombok/DelombokApp.java
@@ -36,7 +36,6 @@ import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import lombok.core.LombokApp;
-import lombok.javac.apt.LombokProcessor;
import lombok.permit.Permit;
import lombok.spi.Provides;
@@ -174,7 +173,6 @@ public class DelombokApp extends LombokApp {
}
private void runDirectly(List<String> args) {
- LombokProcessor.addOpensForLombok();
Delombok.main(args.toArray(new String[0]));
}
diff --git a/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java b/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
index f2cd80e1..bd2f93e7 100644
--- a/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
+++ b/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
@@ -30,7 +30,6 @@ import java.util.List;
import lombok.delombok.Delombok;
import lombok.delombok.Delombok.InvalidFormatOptionException;
-import lombok.javac.apt.LombokProcessor;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Location;
@@ -47,10 +46,6 @@ public class DelombokTaskImpl {
private Path path;
private List<String> formatOptions = new ArrayList<String>();
- static {
- LombokProcessor.addOpensForLombok();
- }
-
public void execute(Location location) throws BuildException {
if (fromDir == null && path == null) throw new BuildException("Either 'from' attribute, or nested <fileset> tags are required.");
if (fromDir != null && path != null) throw new BuildException("You can't specify both 'from' attribute and nested filesets. You need one or the other.");
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index 08e3283f..13acdf55 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -62,15 +62,10 @@ import lombok.delombok.Delombok;
import lombok.javac.CapturingDiagnosticListener;
import lombok.javac.Javac;
import lombok.javac.CapturingDiagnosticListener.CompilerMessage;
-import lombok.javac.apt.LombokProcessor;
public class RunTestsViaDelombok extends AbstractRunTests {
private Delombok delombok = new Delombok();
- static {
- LombokProcessor.addOpensForLombok();
- }
-
@Override
public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, final File file, String encoding, Map<String, String> formatPreferences, int version, boolean checkPositions) throws Throwable {
delombok.setVerbose(true);
diff --git a/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..04cfd9f2
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderSingularCustomized.java
@@ -0,0 +1,77 @@
+import java.util.Set;
+class SuperBuilderSingularCustomized {
+ private Set<String> foos;
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ private java.util.ArrayList<String> foos;
+ public B custom(final String value) {
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.SuppressWarnings("all")
+ public B foo(final String foo) {
+ if (this.foos == null) this.foos = new java.util.ArrayList<String>();
+ this.foos.add(foo);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B foos(final java.util.Collection<? extends String> foos) {
+ if (foos == null) {
+ throw new java.lang.NullPointerException("foos cannot be null");
+ }
+ if (this.foos == null) this.foos = new java.util.ArrayList<String>();
+ this.foos.addAll(foos);
+ return self();
+ }
+ @java.lang.SuppressWarnings("all")
+ public B clearFoos() {
+ if (this.foos != null) this.foos.clear();
+ return self();
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder(foos=" + this.foos + ")";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class SuperBuilderSingularCustomizedBuilderImpl extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<SuperBuilderSingularCustomized, SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private SuperBuilderSingularCustomizedBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderSingularCustomized build() {
+ return new SuperBuilderSingularCustomized(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderSingularCustomized(final SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> b) {
+ java.util.Set<String> foos;
+ switch (b.foos == null ? 0 : b.foos.size()) {
+ case 0:
+ foos = java.util.Collections.emptySet();
+ break;
+ case 1:
+ foos = java.util.Collections.singleton(b.foos.get(0));
+ break;
+ default:
+ foos = new java.util.LinkedHashSet<String>(b.foos.size() < 1073741824 ? 1 + b.foos.size() + (b.foos.size() - 3) / 3 : java.lang.Integer.MAX_VALUE);
+ foos.addAll(b.foos);
+ foos = java.util.Collections.unmodifiableSet(foos);
+ }
+ this.foos = foos;
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> builder() {
+ return new SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java b/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..c6ab1072
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,39 @@
+public class SuperBuilderWithExistingConstructor {
+ public SuperBuilderWithExistingConstructor() {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static abstract class SuperBuilderWithExistingConstructorBuilder<C extends SuperBuilderWithExistingConstructor, B extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<C, B>> {
+ @java.lang.SuppressWarnings("all")
+ protected abstract B self();
+ @java.lang.SuppressWarnings("all")
+ public abstract C build();
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder()";
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ private static final class SuperBuilderWithExistingConstructorBuilderImpl extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<SuperBuilderWithExistingConstructor, SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl> {
+ @java.lang.SuppressWarnings("all")
+ private SuperBuilderWithExistingConstructorBuilderImpl() {
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl self() {
+ return this;
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public SuperBuilderWithExistingConstructor build() {
+ return new SuperBuilderWithExistingConstructor(this);
+ }
+ }
+ @java.lang.SuppressWarnings("all")
+ protected SuperBuilderWithExistingConstructor(final SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> b) {
+ }
+ @java.lang.SuppressWarnings("all")
+ public static SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> builder() {
+ return new SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..613edb03
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderSingularCustomized.java
@@ -0,0 +1,70 @@
+import java.util.Set;
+@lombok.experimental.SuperBuilder class SuperBuilderSingularCustomized {
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ private @java.lang.SuppressWarnings("all") java.util.ArrayList<String> foos;
+ public SuperBuilderSingularCustomizedBuilder() {
+ super();
+ }
+ public B custom(final String value) {
+ return self();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.SuppressWarnings("all") B foo(final String foo) {
+ if ((this.foos == null))
+ this.foos = new java.util.ArrayList<String>();
+ this.foos.add(foo);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B foos(final java.util.Collection<? extends String> foos) {
+ if ((foos == null))
+ {
+ throw new java.lang.NullPointerException("foos cannot be null");
+ }
+ if ((this.foos == null))
+ this.foos = new java.util.ArrayList<String>();
+ this.foos.addAll(foos);
+ return self();
+ }
+ public @java.lang.SuppressWarnings("all") B clearFoos() {
+ if ((this.foos != null))
+ this.foos.clear();
+ return self();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder(foos=" + this.foos) + ")");
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class SuperBuilderSingularCustomizedBuilderImpl extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<SuperBuilderSingularCustomized, SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl> {
+ private SuperBuilderSingularCustomizedBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized build() {
+ return new SuperBuilderSingularCustomized(this);
+ }
+ }
+ private @lombok.Singular Set<String> foos;
+ protected @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized(final SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> b) {
+ super();
+ java.util.Set<String> foos;
+ switch (((b.foos == null) ? 0 : b.foos.size())) {
+ case 0 :
+ foos = java.util.Collections.emptySet();
+ break;
+ case 1 :
+ foos = java.util.Collections.singleton(b.foos.get(0));
+ break;
+ default :
+ foos = new java.util.LinkedHashSet<String>(((b.foos.size() < 0x40000000) ? ((1 + b.foos.size()) + ((b.foos.size() - 3) / 3)) : java.lang.Integer.MAX_VALUE));
+ foos.addAll(b.foos);
+ foos = java.util.Collections.unmodifiableSet(foos);
+ }
+ this.foos = foos;
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<?, ?> builder() {
+ return new SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java b/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..23593691
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,32 @@
+public @lombok.experimental.SuperBuilder class SuperBuilderWithExistingConstructor {
+ public static abstract @java.lang.SuppressWarnings("all") class SuperBuilderWithExistingConstructor<C extends SuperBuilderWithExistingConstructor, B extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<C, B>> {
+ public SuperBuilderWithExistingConstructorBuilder() {
+ super();
+ }
+ protected abstract @java.lang.SuppressWarnings("all") B self();
+ public abstract @java.lang.SuppressWarnings("all") C build();
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return "SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder()";
+ }
+ }
+ private static final @java.lang.SuppressWarnings("all") class SuperBuilderWithExistingConstructorBuilderImpl extends SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<SuperBuilderWithExistingConstructor, SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl> {
+ private SuperBuilderWithExistingConstructorBuilderImpl() {
+ super();
+ }
+ protected @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl self() {
+ return this;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor build() {
+ return new SuperBuilderWithExistingConstructor(this);
+ }
+ }
+ public SuperBuilderWithExistingConstructor() {
+ super();
+ }
+ protected @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor(final SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> b) {
+ super();
+ }
+ public static @java.lang.SuppressWarnings("all") SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilder<?, ?> builder() {
+ return new SuperBuilderWithExistingConstructor.SuperBuilderWithExistingConstructorBuilderImpl();
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/SuperBuilderSingularCustomized.java b/test/transform/resource/before/SuperBuilderSingularCustomized.java
new file mode 100644
index 00000000..86b6022a
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderSingularCustomized.java
@@ -0,0 +1,9 @@
+import java.util.Set;
+@lombok.experimental.SuperBuilder
+class SuperBuilderSingularCustomized {
+ @lombok.Singular private Set<String> foos;
+ public static abstract class SuperBuilderSingularCustomizedBuilder<C extends SuperBuilderSingularCustomized, B extends SuperBuilderSingularCustomized.SuperBuilderSingularCustomizedBuilder<C, B>> {
+ public B custom(final String value) {
+ return self();
+ }
+ }}
diff --git a/test/transform/resource/before/SuperBuilderWithExistingConstructor.java b/test/transform/resource/before/SuperBuilderWithExistingConstructor.java
new file mode 100644
index 00000000..d6bfe2ec
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderWithExistingConstructor.java
@@ -0,0 +1,5 @@
+@lombok.experimental.SuperBuilder
+public class SuperBuilderWithExistingConstructor {
+ public SuperBuilderWithExistingConstructor() {
+ }
+}