From 6ef04d960660b911d8111c9c21f4378db8bbbd9b Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 7 Aug 2026 01:06:21 +0200 Subject: [PATCH] [old-cruft] Removed old `lombok.Delegate` (it's in experimental now) and `lombok.experimental.Wither` (it's in main now). --- doc/changelog.markdown | 1 + src/core/lombok/Delegate.java | 56 ----------- src/core/lombok/experimental/Wither.java | 98 ------------------- .../lombok/javac/handlers/HandleDelegate.java | 6 +- .../resource/after-ecj/BuilderJavadoc.java | 2 +- .../resource/after-ecj/DelegateOnGetter.java | 2 +- .../after-ecj/SuperBuilderJavadoc.java | 2 +- .../resource/after-ecj/Tolerate.java | 2 +- .../resource/after-ecj/WitherAccessLevel.java | 12 +-- .../resource/before/BuilderJavadoc.java | 2 +- .../resource/before/DelegateOnGetter.java | 2 +- .../resource/before/SuperBuilderJavadoc.java | 2 +- test/transform/resource/before/Tolerate.java | 2 +- .../resource/before/WitherAccessLevel.java | 12 +-- 14 files changed, 23 insertions(+), 178 deletions(-) delete mode 100644 src/core/lombok/Delegate.java delete mode 100644 src/core/lombok/experimental/Wither.java diff --git a/doc/changelog.markdown b/doc/changelog.markdown index 618cf710..7375d310 100644 --- a/doc/changelog.markdown +++ b/doc/changelog.markdown @@ -4,6 +4,7 @@ Lombok Changelog ### v1.18.47 "Edgy Guinea Pig" * BUGFIX: `@SneakyThrows` usage on JDK26 no longer results in class files that require `lombok.jar` to be on the runtime classpath (which should not be neccessary). [#4040](https://github.com/projectlombok/lombok/issues/4022). * PROMOTION: `@SuperBuilder` has been promoted to the main package. Otherwise, no changes have been made to the annotation. The old experimental annotation will remain for a few versions, at which point it will be marked as a deprecated annotation. Eventually it'll be removed. If you had `lombok.config` configuration for this annotation, the configuration keys for this feature have been renamed. +* OLD-CRUFT: `lombok.experimental.Wither` and `lombok.Delegate` are deprecated remnants; these features were moved (to respectively `lombok.With` and `lombok.experimental.Delegate` over 5 years ago. They are now removed entirely. If your project is dependent on an older version of lombok which still has those; fret not, lombok still processes these annotations. It just no longer includes them in the jar. ### v1.18.46 (April 22nd, 2026) * PLATFORM: JDK26 support added [#4019](https://github.com/projectlombok/lombok/issues/4019). diff --git a/src/core/lombok/Delegate.java b/src/core/lombok/Delegate.java deleted file mode 100644 index 0c5a4c2c..00000000 --- a/src/core/lombok/Delegate.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2010-2017 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * @deprecated Use {@link lombok.experimental.Delegate} instead. - */ -@Target({ElementType.FIELD, ElementType.METHOD}) -@Retention(RetentionPolicy.SOURCE) -@Deprecated -public @interface Delegate { - /** - * Normally the type of the field is used as delegate type. However, to choose a different type to delegate, you can list one (or more) types here. Note that types with - * type arguments can only be done as a field type. A solution for this is to create a private inner interface/class with the appropriate types extended, and possibly - * with all methods you'd like to delegate listed, and then supply that class here. The field does not actually have to implement the type you're delegating; the - * type listed here is used only to determine which delegate methods to generate. - * - * NB: All methods in {@code Object}, as well as {@code canEqual(Object other)} will never be delegated. - * - * @return For each method (not already in {@code java.lang.Object}) in these types, generate a delegate method. - */ - Class[] types() default {}; - - /** - * Each method in any of the types listed here (include supertypes) will not be delegated. - * - * NB: All methods in {@code Object}, as well as {@code canEqual(Object other)} will never be delegated. - * - * @return For each method (not already in {@code java.lang.Object}) in these types, skip generating a delegate method (overrides {@code types()}). - */ - Class[] excludes() default {}; -} diff --git a/src/core/lombok/experimental/Wither.java b/src/core/lombok/experimental/Wither.java deleted file mode 100644 index cf20c1eb..00000000 --- a/src/core/lombok/experimental/Wither.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (C) 2012-2019 The Project Lombok Authors. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package lombok.experimental; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -import lombok.AccessLevel; - -/** - * Put on any field to make lombok build a 'wither' - a withX method which produces a clone of this object (except for 1 field which gets a new value). - *

- * Complete documentation is found at the project lombok features page for @Wither. - *

- * Even though it is not listed, this annotation also has the {@code onParam} and {@code onMethod} parameter. See the full documentation for more details. - *

- * Example: - *

- *     private @Wither final int foo;
- * 
- * - * will generate: - * - *
- *     public SELF_TYPE withFoo(int foo) {
- *         return this.foo == foo ? this : new SELF_TYPE(otherField1, otherField2, foo);
- *     }
- * 
- *

- * This annotation can also be applied to a class, in which case it'll be as if all non-static fields that don't already have - * a {@code Wither} annotation have the annotation. - * - * @deprecated {@link lombok.With} has been promoted to the main package, so use that one instead. - */ -@Target({ElementType.FIELD, ElementType.TYPE}) -@Retention(RetentionPolicy.SOURCE) -public @interface Wither { - /** - * If you want your wither to be non-public, you can specify an alternate access level here. - * - * @return The method will be generated with this access modifier. - */ - AccessLevel value() default AccessLevel.PUBLIC; - - /** - * Any annotations listed here are put on the generated method. - * The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
- * up to JDK7:
- * {@code @Wither(onMethod=@__({@AnnotationsGoHere}))}
- * from JDK8:
- * {@code @Wither(onMethod_={@AnnotationsGohere})} // note the underscore after {@code onMethod}. - * - * @return List of annotations to apply to the generated method. - */ - AnyAnnotation[] onMethod() default {}; - - /** - * Any annotations listed here are put on the generated method's parameter. - * The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
- * up to JDK7:
- * {@code @Wither(onParam=@__({@AnnotationsGoHere}))}
- * from JDK8:
- * {@code @Wither(onParam_={@AnnotationsGohere})} // note the underscore after {@code onParam}. - * - * @return List of annotations to apply to the generated parameter in the method. - */ - AnyAnnotation[] onParam() default {}; - - /** - * Placeholder annotation to enable the placement of annotations on the generated code. - * @deprecated Don't use this annotation, ever - Read the documentation. - */ - @Deprecated - @Retention(RetentionPolicy.SOURCE) - @Target({}) - @interface AnyAnnotation {} -} diff --git a/src/core/lombok/javac/handlers/HandleDelegate.java b/src/core/lombok/javac/handlers/HandleDelegate.java index 4d72eea3..96c22fa2 100644 --- a/src/core/lombok/javac/handlers/HandleDelegate.java +++ b/src/core/lombok/javac/handlers/HandleDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2021 The Project Lombok Authors. + * Copyright (C) 2010-2026 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -25,7 +25,6 @@ import static com.sun.tools.javac.code.Flags.*; import static lombok.core.handlers.HandlerUtil.handleExperimentalFlagUsage; import static lombok.javac.handlers.JavacHandlerUtil.*; -import java.lang.annotation.Annotation; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; @@ -109,8 +108,7 @@ public class HandleDelegate extends JavacAnnotationHandler { @Override public void handle(AnnotationValues annotation, JCAnnotation ast, JavacNode annotationNode) { handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.DELEGATE_FLAG_USAGE, "@Delegate"); - @SuppressWarnings("deprecation") Class oldDelegate = lombok.Delegate.class; - deleteAnnotationIfNeccessary(annotationNode, Delegate.class, oldDelegate); + deleteAnnotationIfNeccessary(annotationNode, Delegate.class, "lombok.Delegate"); Type delegateType; Name delegateName = annotationNode.toName(annotationNode.up().getName()); diff --git a/test/transform/resource/after-ecj/BuilderJavadoc.java b/test/transform/resource/after-ecj/BuilderJavadoc.java index 75ac875a..c146398e 100644 --- a/test/transform/resource/after-ecj/BuilderJavadoc.java +++ b/test/transform/resource/after-ecj/BuilderJavadoc.java @@ -43,7 +43,7 @@ import java.util.List; } } private final int basic; - private @lombok.Getter @lombok.Setter @lombok.experimental.Wither int getsetwith; + private @lombok.Getter @lombok.Setter @lombok.With int getsetwith; private final int predef; private final int predefWithJavadoc; /** diff --git a/test/transform/resource/after-ecj/DelegateOnGetter.java b/test/transform/resource/after-ecj/DelegateOnGetter.java index 5378257a..ef6281ba 100644 --- a/test/transform/resource/after-ecj/DelegateOnGetter.java +++ b/test/transform/resource/after-ecj/DelegateOnGetter.java @@ -1,4 +1,4 @@ -import lombok.Delegate; +import lombok.experimental.Delegate; import lombok.Getter; class DelegateOnGetter { private interface Bar { diff --git a/test/transform/resource/after-ecj/SuperBuilderJavadoc.java b/test/transform/resource/after-ecj/SuperBuilderJavadoc.java index cc773076..84402dd4 100644 --- a/test/transform/resource/after-ecj/SuperBuilderJavadoc.java +++ b/test/transform/resource/after-ecj/SuperBuilderJavadoc.java @@ -42,7 +42,7 @@ public abstract @lombok.SuperBuilder class SuperBuilderJavadoc { } } private final int basic; - private @lombok.Getter @lombok.Setter @lombok.experimental.Wither int getsetwith; + private @lombok.Getter @lombok.Setter @lombok.With int getsetwith; private final int predef; private final int predefWithJavadoc; protected @java.lang.SuppressWarnings("all") @lombok.Generated SuperBuilderJavadoc(final SuperBuilderJavadoc.SuperBuilderJavadocBuilder b) { diff --git a/test/transform/resource/after-ecj/Tolerate.java b/test/transform/resource/after-ecj/Tolerate.java index 30969918..e6b63ce7 100644 --- a/test/transform/resource/after-ecj/Tolerate.java +++ b/test/transform/resource/after-ecj/Tolerate.java @@ -14,7 +14,7 @@ import java.util.regex.Pattern; return this.pattern; } } -@lombok.Getter @lombok.experimental.Wither @lombok.AllArgsConstructor class Tolerate2 { +@lombok.Getter @lombok.With @lombok.AllArgsConstructor class Tolerate2 { private final Pattern pattern; public @lombok.experimental.Tolerate Tolerate2 withPattern(String pattern) { return withPattern(Pattern.compile(pattern)); diff --git a/test/transform/resource/after-ecj/WitherAccessLevel.java b/test/transform/resource/after-ecj/WitherAccessLevel.java index b0610a11..85a4c4c4 100644 --- a/test/transform/resource/after-ecj/WitherAccessLevel.java +++ b/test/transform/resource/after-ecj/WitherAccessLevel.java @@ -1,11 +1,11 @@ import lombok.AccessLevel; class WitherAccessLevel { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) boolean isNone; - @lombok.experimental.Wither(AccessLevel.PRIVATE) boolean isPrivate; - @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) boolean isPackage; - @lombok.experimental.Wither(AccessLevel.PROTECTED) boolean isProtected; - @lombok.experimental.Wither(lombok.AccessLevel.PUBLIC) boolean isPublic; - @lombok.experimental.Wither(value = lombok.AccessLevel.PUBLIC) boolean value; + @lombok.With(lombok.AccessLevel.NONE) boolean isNone; + @lombok.With(AccessLevel.PRIVATE) boolean isPrivate; + @lombok.With(lombok.AccessLevel.PACKAGE) boolean isPackage; + @lombok.With(AccessLevel.PROTECTED) boolean isProtected; + @lombok.With(lombok.AccessLevel.PUBLIC) boolean isPublic; + @lombok.With(value = lombok.AccessLevel.PUBLIC) boolean value; WitherAccessLevel(boolean isNone, boolean isPrivate, boolean isPackage, boolean isProtected, boolean isPublic, boolean value) { super(); } diff --git a/test/transform/resource/before/BuilderJavadoc.java b/test/transform/resource/before/BuilderJavadoc.java index 390e2096..c69b3252 100644 --- a/test/transform/resource/before/BuilderJavadoc.java +++ b/test/transform/resource/before/BuilderJavadoc.java @@ -17,7 +17,7 @@ class BuilderJavadoc { */ @lombok.Getter @lombok.Setter - @lombok.experimental.Wither + @lombok.With private int getsetwith; /** diff --git a/test/transform/resource/before/DelegateOnGetter.java b/test/transform/resource/before/DelegateOnGetter.java index ad9d1cfb..c5b2cfbc 100644 --- a/test/transform/resource/before/DelegateOnGetter.java +++ b/test/transform/resource/before/DelegateOnGetter.java @@ -1,5 +1,5 @@ //platform !eclipse: Requires a 'full' eclipse with intialized workspace, and we don't (yet) have that set up properly in the test run. -import lombok.Delegate; +import lombok.experimental.Delegate; import lombok.Getter; class DelegateOnGetter { diff --git a/test/transform/resource/before/SuperBuilderJavadoc.java b/test/transform/resource/before/SuperBuilderJavadoc.java index 843aaa4f..0907ec8e 100644 --- a/test/transform/resource/before/SuperBuilderJavadoc.java +++ b/test/transform/resource/before/SuperBuilderJavadoc.java @@ -17,7 +17,7 @@ public abstract class SuperBuilderJavadoc { */ @lombok.Getter @lombok.Setter - @lombok.experimental.Wither + @lombok.With private int getsetwith; /** diff --git a/test/transform/resource/before/Tolerate.java b/test/transform/resource/before/Tolerate.java index d1744aa6..4a5a1a06 100644 --- a/test/transform/resource/before/Tolerate.java +++ b/test/transform/resource/before/Tolerate.java @@ -9,7 +9,7 @@ class Tolerate { } } -@lombok.Getter @lombok.experimental.Wither @lombok.AllArgsConstructor +@lombok.Getter @lombok.With @lombok.AllArgsConstructor class Tolerate2 { private final Pattern pattern; diff --git a/test/transform/resource/before/WitherAccessLevel.java b/test/transform/resource/before/WitherAccessLevel.java index 848be330..c3f659c5 100644 --- a/test/transform/resource/before/WitherAccessLevel.java +++ b/test/transform/resource/before/WitherAccessLevel.java @@ -1,22 +1,22 @@ import lombok.AccessLevel; class WitherAccessLevel { - @lombok.experimental.Wither(lombok.AccessLevel.NONE) + @lombok.With(lombok.AccessLevel.NONE) boolean isNone; - @lombok.experimental.Wither(AccessLevel.PRIVATE) + @lombok.With(AccessLevel.PRIVATE) boolean isPrivate; - @lombok.experimental.Wither(lombok.AccessLevel.PACKAGE) + @lombok.With(lombok.AccessLevel.PACKAGE) boolean isPackage; - @lombok.experimental.Wither(AccessLevel.PROTECTED) + @lombok.With(AccessLevel.PROTECTED) boolean isProtected; - @lombok.experimental.Wither(lombok.AccessLevel.PUBLIC) + @lombok.With(lombok.AccessLevel.PUBLIC) boolean isPublic; - @lombok.experimental.Wither(value=lombok.AccessLevel.PUBLIC) + @lombok.With(value=lombok.AccessLevel.PUBLIC) boolean value; WitherAccessLevel(boolean isNone, boolean isPrivate, boolean isPackage, boolean isProtected, boolean isPublic, boolean value) {