aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/changelog.markdown1
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java24
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleBuilder.java5
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java9
-rw-r--r--src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java14
-rw-r--r--src/core/lombok/eclipse/handlers/HandleLog.java5
-rw-r--r--src/core/lombok/eclipse/handlers/HandleSuperBuilder.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleToString.java4
-rw-r--r--src/core/lombok/eclipse/handlers/HandleVal.java20
-rw-r--r--src/core/lombok/javac/JavacAST.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleBuilder.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java2
-rw-r--r--src/core/lombok/javac/handlers/HandleFieldNameConstants.java14
-rw-r--r--src/core/lombok/javac/handlers/HandleLog.java5
-rw-r--r--src/core/lombok/javac/handlers/HandleNonNull.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleSetter.java1
-rw-r--r--src/core/lombok/javac/handlers/HandleSuperBuilder.java4
-rw-r--r--src/core/lombok/javac/handlers/HandleToString.java7
-rw-r--r--src/core/lombok/javac/handlers/HandleVal.java6
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java30
-rwxr-xr-xsrc/delombok/lombok/delombok/Delombok.java4
-rw-r--r--src/eclipseAgent/lombok/eclipse/agent/PatchVal.java12
-rwxr-xr-xsrc/eclipseAgent/lombok/launch/PatchFixesHider.java1
-rw-r--r--src/installer/lombok/installer/IdeLocation.java12
-rw-r--r--src/installer/lombok/installer/eclipse/EclipseProductLocation.java4
-rw-r--r--src/utils/lombok/eclipse/Eclipse.java7
-rw-r--r--src/utils/lombok/javac/TreeMirrorMaker.java17
-rw-r--r--src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java3
-rw-r--r--test/core/src/lombok/RunTestsViaDelombok.java9
-rw-r--r--test/transform/resource/after-delombok/AccessorsInAnonymousClass.java22
-rw-r--r--test/transform/resource/after-delombok/BuilderInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java34
-rw-r--r--test/transform/resource/after-delombok/DataInAnonymousClass.java56
-rw-r--r--test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java36
-rw-r--r--test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/GetterInAnonymousClass.java13
-rw-r--r--test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java24
-rw-r--r--test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java7
-rw-r--r--test/transform/resource/after-delombok/SetterInAnonymousClass.java13
-rw-r--r--test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java12
-rw-r--r--test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java15
-rw-r--r--test/transform/resource/after-delombok/ToStringInAnonymousClass.java14
-rw-r--r--test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java8
-rw-r--r--test/transform/resource/after-delombok/ValAnonymousSubclassSelfReference.java17
-rw-r--r--test/transform/resource/after-delombok/ValSwitchExpression.java4
-rw-r--r--test/transform/resource/after-delombok/ValToNative.java15
-rw-r--r--test/transform/resource/after-delombok/ValueInAnonymousClass.java46
-rw-r--r--test/transform/resource/after-delombok/WithByInAnonymousClass.java17
-rw-r--r--test/transform/resource/after-delombok/WithInAnonymousClass.java19
-rw-r--r--test/transform/resource/after-ecj/AccessorsInAnonymousClass.java29
-rw-r--r--test/transform/resource/after-ecj/BuilderInAnonymousClass.java17
-rw-r--r--test/transform/resource/after-ecj/ConstructorsInAnonymousClass.java38
-rw-r--r--test/transform/resource/after-ecj/DataInAnonymousClass.java50
-rw-r--r--test/transform/resource/after-ecj/EqualsAndHashCodeInAnonymousClass.java41
-rw-r--r--test/transform/resource/after-ecj/FieldNameConstantsInAnonymousClass.java17
-rw-r--r--test/transform/resource/after-ecj/GetterInAnonymousClass.java20
-rw-r--r--test/transform/resource/after-ecj/GetterLazyInAnonymousClass.java34
-rw-r--r--test/transform/resource/after-ecj/LoggerSlf4jInAnonymousClass.java16
-rw-r--r--test/transform/resource/after-ecj/SetterInAnonymousClass.java20
-rw-r--r--test/transform/resource/after-ecj/SuperBuilderInAnonymousClass.java23
-rw-r--r--test/transform/resource/after-ecj/SynchronizedInAnonymousClass.java23
-rw-r--r--test/transform/resource/after-ecj/ToStringInAnonymousClass.java20
-rw-r--r--test/transform/resource/after-ecj/UtilityClassInAnonymousClass.java17
-rw-r--r--test/transform/resource/after-ecj/ValAnonymousSubclassSelfReference.java23
-rw-r--r--test/transform/resource/after-ecj/ValSwitchExpression.java4
-rw-r--r--test/transform/resource/after-ecj/ValToNative.java19
-rw-r--r--test/transform/resource/after-ecj/ValueInAnonymousClass.java43
-rw-r--r--test/transform/resource/after-ecj/WithByInAnonymousClass.java20
-rw-r--r--test/transform/resource/after-ecj/WithInAnonymousClass.java23
-rw-r--r--test/transform/resource/before/AccessorsInAnonymousClass.java14
-rw-r--r--test/transform/resource/before/BuilderInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/ConstructorsInAnonymousClass.java18
-rw-r--r--test/transform/resource/before/DataInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/EqualsAndHashCodeInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/FieldNameConstantsInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/GetterInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/GetterLazyInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/LoggerSlf4jInAnonymousClass.java9
-rw-r--r--test/transform/resource/before/MixGetterVal.java1
-rw-r--r--test/transform/resource/before/SetterInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/SuperBuilderInAnonymousClass.java15
-rw-r--r--test/transform/resource/before/SynchronizedInAnonymousClass.java12
-rw-r--r--test/transform/resource/before/ToStringInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/TrickyTypeResolution.java1
-rw-r--r--test/transform/resource/before/UtilityClassInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/ValAnonymousSubclassSelfReference.java21
-rw-r--r--test/transform/resource/before/ValAnonymousSubclassWithGenerics.java1
-rw-r--r--test/transform/resource/before/ValComplex.java1
-rw-r--r--test/transform/resource/before/ValDefault.java2
-rw-r--r--test/transform/resource/before/ValDelegateMethodReference.java2
-rw-r--r--test/transform/resource/before/ValErrors.java1
-rw-r--r--test/transform/resource/before/ValFinal.java1
-rw-r--r--test/transform/resource/before/ValInBasicFor.java1
-rw-r--r--test/transform/resource/before/ValInFor.java1
-rw-r--r--test/transform/resource/before/ValInLambda.java2
-rw-r--r--test/transform/resource/before/ValInMultiDeclaration.java1
-rw-r--r--test/transform/resource/before/ValInTryWithResources.java2
-rw-r--r--test/transform/resource/before/ValLambda.java2
-rw-r--r--test/transform/resource/before/ValLessSimple.java1
-rw-r--r--test/transform/resource/before/ValLub.java1
-rw-r--r--test/transform/resource/before/ValNullInit.java1
-rw-r--r--test/transform/resource/before/ValOutersWithGenerics.java1
-rw-r--r--test/transform/resource/before/ValRawType.java1
-rw-r--r--test/transform/resource/before/ValSimple.java1
-rw-r--r--test/transform/resource/before/ValToNative.java19
-rw-r--r--test/transform/resource/before/ValWeirdTypes.java2
-rw-r--r--test/transform/resource/before/ValWithLabel.java1
-rw-r--r--test/transform/resource/before/ValWithLocalClasses.java1
-rw-r--r--test/transform/resource/before/ValWithSelfRefGenerics.java1
-rw-r--r--test/transform/resource/before/ValueInAnonymousClass.java10
-rw-r--r--test/transform/resource/before/WithByInAnonymousClass.java13
-rw-r--r--test/transform/resource/before/WithInAnonymousClass.java12
-rw-r--r--test/transform/resource/messages-delombok/BuilderInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/FieldNameConstantsInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/LoggerSlf4jInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-delombok/SuperBuilderInAnonymousClass.java.messages2
-rw-r--r--test/transform/resource/messages-delombok/UtilityClassInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/BuilderInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/FieldNameConstantsInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/LoggerSlf4jInAnonymousClass.java.messages1
-rw-r--r--test/transform/resource/messages-ecj/SuperBuilderInAnonymousClass.java.messages2
-rw-r--r--test/transform/resource/messages-ecj/UtilityClassInAnonymousClass.java.messages1
-rw-r--r--website/templates/features/val.html3
123 files changed, 1328 insertions, 67 deletions
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 583736f1..973d86ea 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -3,6 +3,7 @@ Lombok Changelog
### v1.18.21 "Edgy Guinea Pig"
* Added the `@StandardException` feature. [Pull Request #2702](https://github.com/projectlombok/lombok/pull/2702).
+* IMPROBABLE BREAKING CHANGE: If the underlying compiler and `--release` / `--source` option is 10 or higher, lombok's `val` is now replaced by `final var`. That means compound declarations such as `val x = 10, y = 12;` now fail (lombok's old `val` implementation supported it, javac's `var` does not), but IDE support in particular is more reliable. We decided it was worth the tradeoff.
### v1.18.20 (April 2nd, 2021)
* PLATFORM: JDK16 support added. [Issue #2681](https://github.com/projectlombok/lombok/issues/2681).
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 5eea980c..a9f435fd 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -1042,7 +1042,7 @@ public class EclipseHandlerUtil {
res[count] = name;
n = parent;
- while (n != null && n.getKind() == Kind.TYPE && n.get() instanceof TypeDeclaration) {
+ while (count > 0) {
TypeDeclaration td = (TypeDeclaration) n.get();
res[--count] = td.name;
n = n.up();
@@ -2636,6 +2636,13 @@ public class EclipseHandlerUtil {
}
/**
+ * Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
+ */
+ public static boolean isClassEnumOrRecord(EclipseNode typeNode) {
+ return isTypeAndDoesNotHaveFlags(typeNode, ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation);
+ }
+
+ /**
* Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
*/
public static boolean isRecord(EclipseNode typeNode) {
@@ -2662,6 +2669,21 @@ public class EclipseHandlerUtil {
return (modifiers & flags) == 0;
}
+ /**
+ * Returns {@code true} if the provided node supports static methods and types (top level or static class)
+ */
+ public static boolean isStaticAllowed(EclipseNode typeNode) {
+ boolean staticAllowed = true;
+
+ while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
+ if (!staticAllowed) return false;
+
+ staticAllowed = typeNode.isStatic();
+ typeNode = typeNode.up();
+ }
+ return true;
+ }
+
public static AbstractVariableDeclaration[] getRecordComponents(TypeDeclaration typeDeclaration) {
if (typeDeclaration == null || (typeDeclaration.modifiers & AccRecord) == 0) return null;
try {
diff --git a/src/core/lombok/eclipse/handlers/HandleBuilder.java b/src/core/lombok/eclipse/handlers/HandleBuilder.java
index dab774f3..82d3bfcf 100755
--- a/src/core/lombok/eclipse/handlers/HandleBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleBuilder.java
@@ -293,6 +293,11 @@ public class HandleBuilder extends EclipseAnnotationHandler<Builder> {
List<EclipseNode> nonFinalNonDefaultedFields = null;
+ if (!isStaticAllowed(upToTypeNode(parent))) {
+ annotationNode.addError("@Builder is not supported on non-static nested classes.");
+ return;
+ }
+
if (parent.get() instanceof TypeDeclaration) {
if (!isClass(parent) && !isRecord(parent)) {
annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index 12a3c315..a5e8dfb5 100755
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -538,14 +538,15 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
if (addWildcards) genericsCount.add(arraySizeOf(((TypeDeclaration) type.get()).typeParameters));
boolean staticContext = (((TypeDeclaration) type.get()).modifiers & ClassFileConstants.AccStatic) != 0;
EclipseNode tNode = type.up();
- if (!staticContext && tNode.getKind() == Kind.TYPE && (((TypeDeclaration) tNode.get()).modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
while (tNode != null && tNode.getKind() == Kind.TYPE) {
+ TypeDeclaration td = (TypeDeclaration) tNode.get();
+ if (td.name == null || td.name.length == 0) break;
list.add(tNode.getName());
- if (addWildcards) genericsCount.add(staticContext ? 0 : arraySizeOf(((TypeDeclaration) tNode.get()).typeParameters));
- if (!staticContext) staticContext = (((TypeDeclaration) tNode.get()).modifiers & Modifier.STATIC) != 0;
+ if (!staticContext && tNode.getKind() == Kind.TYPE && (td.modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
+ if (addWildcards) genericsCount.add(staticContext ? 0 : arraySizeOf(td.typeParameters));
+ if (!staticContext) staticContext = (td.modifiers & Modifier.STATIC) != 0;
tNode = tNode.up();
- if (!staticContext && tNode.getKind() == Kind.TYPE && (((TypeDeclaration) tNode.get()).modifiers & ClassFileConstants.AccInterface) != 0) staticContext = true;
}
Collections.reverse(list);
if (addWildcards) Collections.reverse(genericsCount);
diff --git a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
index cc1a5c3f..071dcdfb 100644
--- a/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/eclipse/handlers/HandleFieldNameConstants.java
@@ -60,14 +60,12 @@ public class HandleFieldNameConstants extends EclipseAnnotationHandler<FieldName
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
public void generateFieldNameConstantsForType(EclipseNode typeNode, EclipseNode errorNode, AccessLevel level, boolean asEnum, IdentifierName innerTypeName, boolean onlyExplicit, boolean uppercase) {
- TypeDeclaration typeDecl = null;
- if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
-
- int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
- boolean notAClass = (modifiers & (ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
-
- if (typeDecl == null || notAClass) {
- errorNode.addError("@FieldNameConstants is only supported on a class or an enum.");
+ if (!isClassEnumOrRecord(typeNode)) {
+ errorNode.addError("@FieldNameConstants is only supported on a class, an enum or a record.");
+ return;
+ }
+ if (!isStaticAllowed(typeNode)) {
+ errorNode.addError("@FieldNameConstants is not supported on non-static nested classes.");
return;
}
diff --git a/src/core/lombok/eclipse/handlers/HandleLog.java b/src/core/lombok/eclipse/handlers/HandleLog.java
index 1cac2de7..db9104ef 100644
--- a/src/core/lombok/eclipse/handlers/HandleLog.java
+++ b/src/core/lombok/eclipse/handlers/HandleLog.java
@@ -88,6 +88,11 @@ public class HandleLog {
return;
}
+ if (useStatic && !isStaticAllowed(owner)) {
+ annotationNode.addError(framework.getAnnotationAsString() + " is not supported on non-static nested classes.");
+ return;
+ }
+
Object valueGuess = annotation.getValueGuess("topic");
Expression loggerTopic = (Expression) annotation.getActualExpression("topic");
diff --git a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
index 4d5d2448..5bc6c125 100644
--- a/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/eclipse/handlers/HandleSuperBuilder.java
@@ -184,6 +184,10 @@ public class HandleSuperBuilder extends EclipseAnnotationHandler<SuperBuilder> {
annotationNode.addError("@SuperBuilder is only supported on classes.");
return;
}
+ if (!isStaticAllowed(parent)) {
+ annotationNode.addError("@SuperBuilder is not supported on non-static nested classes.");
+ return;
+ }
job.parentType = parent;
TypeDeclaration td = (TypeDeclaration) parent.get();
diff --git a/src/core/lombok/eclipse/handlers/HandleToString.java b/src/core/lombok/eclipse/handlers/HandleToString.java
index 171402b3..05b0e069 100644
--- a/src/core/lombok/eclipse/handlers/HandleToString.java
+++ b/src/core/lombok/eclipse/handlers/HandleToString.java
@@ -315,7 +315,9 @@ public class HandleToString extends EclipseAnnotationHandler<ToString> {
String typeName = getSingleTypeName(type);
EclipseNode upType = type.up();
while (upType.getKind() == Kind.TYPE) {
- typeName = getSingleTypeName(upType) + "." + typeName;
+ String upTypeName = getSingleTypeName(upType);
+ if (upTypeName.isEmpty()) break;
+ typeName = upTypeName + "." + typeName;
upType = upType.up();
}
return typeName;
diff --git a/src/core/lombok/eclipse/handlers/HandleVal.java b/src/core/lombok/eclipse/handlers/HandleVal.java
index ac53e27e..0f70e66d 100644
--- a/src/core/lombok/eclipse/handlers/HandleVal.java
+++ b/src/core/lombok/eclipse/handlers/HandleVal.java
@@ -22,12 +22,14 @@
package lombok.eclipse.handlers;
import static lombok.core.handlers.HandlerUtil.handleFlagUsage;
-import static lombok.eclipse.handlers.EclipseHandlerUtil.typeMatches;
+import static lombok.eclipse.handlers.EclipseHandlerUtil.*;
+
import lombok.ConfigurationKeys;
import lombok.val;
import lombok.var;
import lombok.core.HandlerPriority;
import lombok.eclipse.DeferUntilPostDiet;
+import lombok.eclipse.Eclipse;
import lombok.eclipse.EclipseASTAdapter;
import lombok.eclipse.EclipseASTVisitor;
import lombok.eclipse.EclipseNode;
@@ -39,10 +41,13 @@ import org.eclipse.jdt.internal.compiler.ast.ForStatement;
import org.eclipse.jdt.internal.compiler.ast.ForeachStatement;
import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration;
import org.eclipse.jdt.internal.compiler.ast.NullLiteral;
+import org.eclipse.jdt.internal.compiler.ast.SingleTypeReference;
import org.eclipse.jdt.internal.compiler.ast.TypeReference;
+import org.eclipse.jdt.internal.compiler.classfmt.ClassFileConstants;
/*
- * This class just handles 3 basic error cases. The real meat of eclipse 'val' support is in {@code PatchVal} and {@code PatchValEclipse}.
+ * Java 1-9: This class just handles 3 basic error cases. The real meat of eclipse 'val' support is in {@code PatchVal} and {@code PatchValEclipse}.
+ * Java 10+: Lombok uses the native 'var' support and transforms 'val' to 'final var'.
*/
@Provides(EclipseASTVisitor.class)
@DeferUntilPostDiet
@@ -96,5 +101,16 @@ public class HandleVal extends EclipseASTAdapter {
localNode.addError("variable initializer is 'null'");
return;
}
+
+ // For Java >= 10 we use native support
+ if (localNode.getSourceVersion() >= 10) {
+ if (isVal) {
+ TypeReference originalType = local.type;
+ local.type = new SingleTypeReference("var".toCharArray(), Eclipse.pos(local.type));
+ local.modifiers |= ClassFileConstants.AccFinal;
+ local.annotations = addAnnotation(local.type, local.annotations, originalType.getTypeName());
+ }
+ return;
+ }
}
}
diff --git a/src/core/lombok/javac/JavacAST.java b/src/core/lombok/javac/JavacAST.java
index f58de60f..0919c7d4 100644
--- a/src/core/lombok/javac/JavacAST.java
+++ b/src/core/lombok/javac/JavacAST.java
@@ -228,7 +228,7 @@ public class JavacAST extends AST<JavacAST, JavacNode, JCTree> {
int underscoreIdx = nm.indexOf('_');
if (underscoreIdx > -1) return Integer.parseInt(nm.substring(underscoreIdx + 1));
// assume java9+
- return Integer.parseInt(nm);
+ return Integer.parseInt(nm.substring(3));
} catch (Exception ignore) {}
return 6;
}
diff --git a/src/core/lombok/javac/handlers/HandleBuilder.java b/src/core/lombok/javac/handlers/HandleBuilder.java
index c23dc14c..bb852b55 100644
--- a/src/core/lombok/javac/handlers/HandleBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleBuilder.java
@@ -234,6 +234,11 @@ public class HandleBuilder extends JavacAnnotationHandler<Builder> {
ArrayList<JavacNode> nonFinalNonDefaultedFields = null;
+ if (!isStaticAllowed(upToTypeNode(parent))) {
+ annotationNode.addError("@Builder is not supported on non-static nested classes.");
+ return;
+ }
+
if (parent.get() instanceof JCClassDecl) {
if (!isClass(parent) && !isRecord(parent)) {
annotationNode.addError(BUILDER_NODE_NOT_SUPPORTED_ERR);
diff --git a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
index ffe882d8..dace3521 100644
--- a/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/javac/handlers/HandleEqualsAndHashCode.java
@@ -385,7 +385,7 @@ public class HandleEqualsAndHashCode extends JavacAnnotationHandler<EqualsAndHas
boolean staticContext = (((JCClassDecl) type.get()).getModifiers().flags & Flags.STATIC) != 0;
JavacNode tNode = type.up();
- while (tNode != null && tNode.getKind() == Kind.TYPE) {
+ while (tNode != null && tNode.getKind() == Kind.TYPE && !tNode.getName().isEmpty()) {
list.add(tNode.getName());
if (addWildcards) genericsCount.add(staticContext ? 0 : ((JCClassDecl) tNode.get()).typarams.size());
if (!staticContext) staticContext = (((JCClassDecl) tNode.get()).getModifiers().flags & Flags.STATIC) != 0;
diff --git a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
index f3c879d5..1fc6beb1 100644
--- a/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
+++ b/src/core/lombok/javac/handlers/HandleFieldNameConstants.java
@@ -57,14 +57,12 @@ public class HandleFieldNameConstants extends JavacAnnotationHandler<FieldNameCo
private static final IdentifierName FIELDS = IdentifierName.valueOf("Fields");
public void generateFieldNameConstantsForType(JavacNode typeNode, JavacNode errorNode, AccessLevel level, boolean asEnum, IdentifierName innerTypeName, boolean onlyExplicit, boolean uppercase) {
- JCClassDecl typeDecl = null;
- if (typeNode.get() instanceof JCClassDecl) typeDecl = (JCClassDecl) typeNode.get();
-
- long modifiers = typeDecl == null ? 0 : typeDecl.mods.flags;
- boolean notAClass = (modifiers & (Flags.INTERFACE | Flags.ANNOTATION)) != 0;
-
- if (typeDecl == null || notAClass) {
- errorNode.addError("@FieldNameConstants is only supported on a class or an enum.");
+ if (!isClassEnumOrRecord(typeNode)) {
+ errorNode.addError("@FieldNameConstants is only supported on a class, an enum or a record.");
+ return;
+ }
+ if (!isStaticAllowed(typeNode)) {
+ errorNode.addError("@FieldNameConstants is not supported on non-static nested classes.");
return;
}
diff --git a/src/core/lombok/javac/handlers/HandleLog.java b/src/core/lombok/javac/handlers/HandleLog.java
index 40f7ff08..957f5581 100644
--- a/src/core/lombok/javac/handlers/HandleLog.java
+++ b/src/core/lombok/javac/handlers/HandleLog.java
@@ -80,6 +80,11 @@ public class HandleLog {
return;
}
+ if (useStatic && !isStaticAllowed(typeNode)) {
+ annotationNode.addError(framework.getAnnotationAsString() + " is not supported on non-static nested classes.");
+ return;
+ }
+
Object valueGuess = annotation.getValueGuess("topic");
JCExpression loggerTopic = (JCExpression) annotation.getActualExpression("topic");
diff --git a/src/core/lombok/javac/handlers/HandleNonNull.java b/src/core/lombok/javac/handlers/HandleNonNull.java
index fe66432a..271bedbb 100644
--- a/src/core/lombok/javac/handlers/HandleNonNull.java
+++ b/src/core/lombok/javac/handlers/HandleNonNull.java
@@ -99,7 +99,6 @@ public class HandleNonNull extends JavacAnnotationHandler<NonNull> {
return recursiveSetGeneratedBy(constr, source);
} else {
existingCtr.mods = mods;
- existingCtr.params = params.toList();
existingCtr.body = body;
existingCtr = recursiveSetGeneratedBy(existingCtr, source);
addSuppressWarningsAll(existingCtr.mods, typeNode, typeNode.getNodeFor(getGeneratedBy(existingCtr)), typeNode.getContext());
diff --git a/src/core/lombok/javac/handlers/HandleSetter.java b/src/core/lombok/javac/handlers/HandleSetter.java
index a0634494..e5b2c062 100644
--- a/src/core/lombok/javac/handlers/HandleSetter.java
+++ b/src/core/lombok/javac/handlers/HandleSetter.java
@@ -43,7 +43,6 @@ import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCAssign;
import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCReturn;
diff --git a/src/core/lombok/javac/handlers/HandleSuperBuilder.java b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
index 87b18576..50193f99 100644
--- a/src/core/lombok/javac/handlers/HandleSuperBuilder.java
+++ b/src/core/lombok/javac/handlers/HandleSuperBuilder.java
@@ -163,6 +163,10 @@ public class HandleSuperBuilder extends JavacAnnotationHandler<SuperBuilder> {
annotationNode.addError("@SuperBuilder is only supported on classes.");
return;
}
+ if (!isStaticAllowed(parent)) {
+ annotationNode.addError("@SuperBuilder is not supported on non-static nested classes.");
+ return;
+ }
job.parentType = parent;
JCClassDecl td = (JCClassDecl) parent.get();
diff --git a/src/core/lombok/javac/handlers/HandleToString.java b/src/core/lombok/javac/handlers/HandleToString.java
index 3fc6a4e4..249993ee 100644
--- a/src/core/lombok/javac/handlers/HandleToString.java
+++ b/src/core/lombok/javac/handlers/HandleToString.java
@@ -44,7 +44,6 @@ import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.tree.JCTree.JCAnnotation;
import com.sun.tools.javac.tree.JCTree.JCArrayTypeTree;
import com.sun.tools.javac.tree.JCTree.JCBlock;
-import com.sun.tools.javac.tree.JCTree.JCClassDecl;
import com.sun.tools.javac.tree.JCTree.JCExpression;
import com.sun.tools.javac.tree.JCTree.JCMethodDecl;
import com.sun.tools.javac.tree.JCTree.JCMethodInvocation;
@@ -252,10 +251,10 @@ public class HandleToString extends JavacAnnotationHandler<ToString> {
}
public static String getTypeName(JavacNode typeNode) {
- String typeName = ((JCClassDecl) typeNode.get()).name.toString();
+ String typeName = typeNode.getName();
JavacNode upType = typeNode.up();
- while (upType.getKind() == Kind.TYPE) {
- typeName = ((JCClassDecl) upType.get()).name.toString() + "." + typeName;
+ while (upType.getKind() == Kind.TYPE && !upType.getName().isEmpty()) {
+ typeName = upType.getName() + "." + typeName;
upType = upType.up();
}
return typeName;
diff --git a/src/core/lombok/javac/handlers/HandleVal.java b/src/core/lombok/javac/handlers/HandleVal.java
index 0ed831ab..d4fb1027 100644
--- a/src/core/lombok/javac/handlers/HandleVal.java
+++ b/src/core/lombok/javac/handlers/HandleVal.java
@@ -115,6 +115,12 @@ public class HandleVal extends JavacASTAdapter {
local.mods.annotations = local.mods.annotations == null ? List.of(valAnnotation) : local.mods.annotations.append(valAnnotation);
}
+ if (localNode.getSourceVersion() >= 10) {
+ local.vartype = null;
+ localNode.getAst().setChanged();
+ return;
+ }
+
if (JavacResolution.platformHasTargetTyping()) {
local.vartype = localNode.getAst().getTreeMaker().Ident(localNode.getAst().toName("___Lombok_VAL_Attrib__"));
} else {
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 78c20d39..a41264e8 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -106,6 +106,7 @@ import lombok.javac.Javac;
import lombok.javac.JavacAugments;
import lombok.javac.JavacNode;
import lombok.javac.JavacTreeMaker;
+import lombok.javac.JavacTreeMaker.TypeTag;
import lombok.permit.Permit;
/**
@@ -1286,6 +1287,7 @@ public class JavacHandlerUtil {
static Type classEnter(JCTree tree, JavacNode parent) {
Enter enter = Enter.instance(parent.getContext());
Env<AttrContext> classEnv = enter.getEnv((TypeSymbol) parent.getElement());
+ if (classEnv == null) return null;
Type type = (Type) Permit.invokeSneaky(classEnter, enter, tree, classEnv);
if (type == null) return null;
type.complete();
@@ -1902,7 +1904,7 @@ public class JavacHandlerUtil {
public static JCExpression namePlusTypeParamsToTypeReference(JavacTreeMaker maker, JavacNode parentType, Name typeName, boolean instance, List<JCTypeParameter> params, List<JCAnnotation> annotations) {
JCExpression r = null;
- if (parentType != null && parentType.getKind() == Kind.TYPE) {
+ if (parentType != null && parentType.getKind() == Kind.TYPE && !parentType.getName().isEmpty()) {
JCClassDecl td = (JCClassDecl) parentType.get();
boolean outerInstance = instance && ((td.mods.flags & Flags.STATIC) == 0);
List<JCTypeParameter> outerParams = instance ? td.typarams : List.<JCTypeParameter>nil();
@@ -1979,6 +1981,13 @@ public class JavacHandlerUtil {
}
/**
+ * Returns {@code true} if the provided node is an actual class, an enum or a record and not some other type declaration (so, not an annotation definition or interface).
+ */
+ public static boolean isClassEnumOrRecord(JavacNode typeNode) {
+ return isClassAndDoesNotHaveFlags(typeNode, Flags.INTERFACE | Flags.ANNOTATION);
+ }
+
+ /**
* Returns {@code true} if the provided node is a record declaration (so, not an annotation definition, interface, enum, or plain class).
*/
public static boolean isRecord(JavacNode typeNode) {
@@ -1994,6 +2003,21 @@ public class JavacHandlerUtil {
return (typeDeclflags & flags) == 0;
}
+ /**
+ * Returns {@code true} if the provided node supports static methods and types (top level or static class)
+ */
+ public static boolean isStaticAllowed(JavacNode typeNode) {
+ boolean staticAllowed = true;
+
+ while (typeNode.getKind() != Kind.COMPILATION_UNIT) {
+ if (!staticAllowed) return false;
+
+ staticAllowed = typeNode.isStatic();
+ typeNode = typeNode.up();
+ }
+ return true;
+ }
+
public static JavacNode upToTypeNode(JavacNode node) {
if (node == null) throw new NullPointerException("node");
while ((node != null) && !(node.get() instanceof JCClassDecl)) node = node.up();
@@ -2028,7 +2052,9 @@ public class JavacHandlerUtil {
private static JCExpression cloneType0(JavacTreeMaker maker, JCTree in) {
if (in == null) return null;
- if (in instanceof JCPrimitiveTypeTree) return (JCExpression) in;
+ if (in instanceof JCPrimitiveTypeTree) {
+ return maker.TypeIdent(TypeTag.typeTag(in));
+ }
if (in instanceof JCIdent) {
return maker.Ident(((JCIdent) in).name);
diff --git a/src/delombok/lombok/delombok/Delombok.java b/src/delombok/lombok/delombok/Delombok.java
index 8d39f447..e4f17602 100755
--- a/src/delombok/lombok/delombok/Delombok.java
+++ b/src/delombok/lombok/delombok/Delombok.java
@@ -43,9 +43,9 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
@@ -733,7 +733,7 @@ public class Delombok {
List<JCCompilationUnit> roots = new ArrayList<JCCompilationUnit>();
Map<JCCompilationUnit, File> baseMap = new IdentityHashMap<JCCompilationUnit, File>();
- Set<AbstractProcessor> processors = new HashSet<AbstractProcessor>();
+ Set<AbstractProcessor> processors = new LinkedHashSet<AbstractProcessor>();
processors.add(new lombok.javac.apt.LombokProcessor());
processors.addAll(additionalAnnotationProcessors);
diff --git a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
index 774e5b40..824ecefc 100644
--- a/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
+++ b/src/eclipseAgent/lombok/eclipse/agent/PatchVal.java
@@ -204,6 +204,8 @@ public class PatchVal {
boolean var = isVar(local, scope);
if (!(val || var)) return false;
+ if (hasNativeVarSupport(scope)) return false;
+
if (val) {
StackTraceElement[] st = new Throwable().getStackTrace();
for (int i = 0; i < st.length - 2 && i < 10; i++) {
@@ -281,6 +283,14 @@ public class PatchVal {
return is(local.type, scope, "lombok.val");
}
+ private static boolean hasNativeVarSupport(Scope scope) {
+ long sl = scope.problemReporter().options.sourceLevel >> 16;
+ long cl = scope.problemReporter().options.complianceLevel >> 16;
+ if (sl == 0) sl = cl;
+ if (cl == 0) cl = sl;
+ return Math.min((int)(sl - 44), (int)(cl - 44)) >= 10;
+ }
+
public static boolean handleValForForEach(ForeachStatement forEach, BlockScope scope) {
if (forEach.elementVariable == null) return false;
@@ -288,6 +298,8 @@ public class PatchVal {
boolean var = isVar(forEach.elementVariable, scope);
if (!(val || var)) return false;
+ if (hasNativeVarSupport(scope)) return false;
+
TypeBinding component = getForEachComponentType(forEach.collection, scope);
if (component == null) return false;
TypeReference replacement = makeType(component, forEach.elementVariable.type, false);
diff --git a/src/eclipseAgent/lombok/launch/PatchFixesHider.java b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
index bee30922..30c63cf0 100755
--- a/src/eclipseAgent/lombok/launch/PatchFixesHider.java
+++ b/src/eclipseAgent/lombok/launch/PatchFixesHider.java
@@ -419,6 +419,7 @@ final class PatchFixesHider {
String className = visitor.getClass().getName();
if (!(className.startsWith("org.eclipse.jdt.internal.corext.fix") || className.startsWith("org.eclipse.jdt.internal.ui.fix"))) return false;
+ if (className.equals("org.eclipse.jdt.internal.corext.fix.VariableDeclarationFixCore$WrittenNamesFinder")) return false;
boolean result = false;
try {
diff --git a/src/installer/lombok/installer/IdeLocation.java b/src/installer/lombok/installer/IdeLocation.java
index 6b9a94c6..7cba1e2a 100644
--- a/src/installer/lombok/installer/IdeLocation.java
+++ b/src/installer/lombok/installer/IdeLocation.java
@@ -64,16 +64,4 @@ public abstract class IdeLocation {
return x == null ? p.getPath() : x;
}
}
-
- private static final String LEGAL_PATH_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/";
- private static final String LEGAL_PATH_CHARS_WINDOWS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.,/;'[]{}!@#$^&()-_+= :\\";
- public static String escapePath(String path) {
- StringBuilder out = new StringBuilder();
- String legalChars = OsUtils.getOS() == OsUtils.OS.UNIX ? LEGAL_PATH_CHARS : LEGAL_PATH_CHARS_WINDOWS;
- for (char c : path.toCharArray()) {
- if (legalChars.indexOf(c) == -1) out.append('\\');
- out.append(c);
- }
- return out.toString();
- }
}
diff --git a/src/installer/lombok/installer/eclipse/EclipseProductLocation.java b/src/installer/lombok/installer/eclipse/EclipseProductLocation.java
index 73f98a35..4cfd07f5 100644
--- a/src/installer/lombok/installer/eclipse/EclipseProductLocation.java
+++ b/src/installer/lombok/installer/eclipse/EclipseProductLocation.java
@@ -347,8 +347,10 @@ public final class EclipseProductLocation extends IdeLocation {
pathPrefix = pathToLombokJarPrefix;
}
+ // NB: You may be tempted to escape this, but don't; there is no possibility to escape this, but
+ // eclipse/java reads the string following the colon in 'raw' fashion. Spaces, colons - all works fine.
newContents.append(String.format(
- "-javaagent:%s", escapePath(pathPrefix + "lombok.jar"))).append(OS_NEWLINE);
+ "-javaagent:%s", pathPrefix + "lombok.jar")).append(OS_NEWLINE);
FileOutputStream fos = new FileOutputStream(eclipseIniPath);
try {
diff --git a/src/utils/lombok/eclipse/Eclipse.java b/src/utils/lombok/eclipse/Eclipse.java
index 8af481b9..0f42ddc6 100644
--- a/src/utils/lombok/eclipse/Eclipse.java
+++ b/src/utils/lombok/eclipse/Eclipse.java
@@ -224,8 +224,11 @@ public class Eclipse {
int highestVersionSoFar = 0;
for (Field f : ClassFileConstants.class.getDeclaredFields()) {
try {
- if (f.getName().startsWith("JDK1_")) {
- int thisVersion = Integer.parseInt(f.getName().substring("JDK1_".length()));
+ if (f.getName().startsWith("JDK")) {
+ String versionString = f.getName().substring("JDK".length());
+ if (versionString.startsWith("1_")) versionString = versionString.substring("1_".length());
+
+ int thisVersion = Integer.parseInt(versionString);
if (thisVersion > highestVersionSoFar) {
highestVersionSoFar = thisVersion;
latestEcjCompilerVersionConstantCached = (Long) f.get(null);
diff --git a/src/utils/lombok/javac/TreeMirrorMaker.java b/src/utils/lombok/javac/TreeMirrorMaker.java
index a67a4ec1..44e26ab6 100644
--- a/src/utils/lombok/javac/TreeMirrorMaker.java
+++ b/src/utils/lombok/javac/TreeMirrorMaker.java
@@ -32,8 +32,10 @@ import lombok.javac.JavacTreeMaker.TypeTag;
import com.sun.source.tree.LabeledStatementTree;
import com.sun.source.tree.VariableTree;
import com.sun.tools.javac.tree.JCTree;
+import com.sun.tools.javac.tree.JCTree.JCFieldAccess;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;
import com.sun.tools.javac.tree.TreeCopier;
+import com.sun.tools.javac.tree.TreeScanner;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.List;
@@ -109,6 +111,21 @@ public class TreeMirrorMaker extends TreeCopier<Void> {
if (wipeSymAndType) {
copy.sym = null;
copy.type = null;
+ } else {
+ if (original.vartype != null) {
+ copy.vartype.type = original.vartype.type;
+ original.vartype.accept(new TreeScanner() {
+ @Override public void scan(JCTree tree) {
+ super.scan(tree);
+ originalToCopy.get(tree).type = tree.type;
+ }
+
+ @Override public void visitSelect(JCFieldAccess tree) {
+ super.visitSelect(tree);
+ ((JCFieldAccess) originalToCopy.get(tree)).sym = tree.sym;
+ }
+ });
+ }
}
}
diff --git a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
index f29f501b..e625cd8d 100644
--- a/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
+++ b/src/utils/lombok/javac/java8/CommentCollectingScannerFactory.java
@@ -21,6 +21,7 @@
*/
package lombok.javac.java8;
+import java.nio.Buffer;
import java.nio.CharBuffer;
import com.sun.tools.javac.parser.Scanner;
@@ -79,7 +80,7 @@ public class CommentCollectingScannerFactory extends ScannerFactory {
int limit;
if (input instanceof CharBuffer && ((CharBuffer) input).hasArray()) {
CharBuffer cb = (CharBuffer) input;
- cb.compact().flip();
+ ((Buffer)cb.compact()).flip();
array = cb.array();
limit = cb.limit();
} else {
diff --git a/test/core/src/lombok/RunTestsViaDelombok.java b/test/core/src/lombok/RunTestsViaDelombok.java
index 23a42c67..e4eb1a30 100644
--- a/test/core/src/lombok/RunTestsViaDelombok.java
+++ b/test/core/src/lombok/RunTestsViaDelombok.java
@@ -42,7 +42,6 @@ import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.RoundEnvironment;
import javax.lang.model.SourceVersion;
import javax.lang.model.element.Element;
-import javax.lang.model.element.ElementKind;
import javax.lang.model.element.TypeElement;
import com.sun.source.util.TreePath;
@@ -211,8 +210,8 @@ public class RunTestsViaDelombok extends AbstractRunTests {
}
@Override public void visitVarDef(JCVariableDecl tree) {
- // Skip non-field variables
- if (!(parent instanceof JCClassDecl)) return;
+ // Skip local variables
+ if (!(parent instanceof JCClassDecl || parent instanceof JCMethodDecl)) return;
validateSymbol(tree, tree.sym);
super.visitVarDef(tree);
@@ -222,8 +221,8 @@ public class RunTestsViaDelombok extends AbstractRunTests {
if (sym == null) {
fail("Missing symbol for " + tree);
}
- // Skip top level classes
- if (sym.owner.getKind() == ElementKind.PACKAGE) return;
+ // Only classes have enclosed elements, skip everything else
+ if (!sym.owner.getKind().isClass()) return;
if (!sym.owner.getEnclosedElements().contains(sym)) {
fail(tree + " not added to parent");
diff --git a/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java b/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java
new file mode 100644
index 00000000..27fab509
--- /dev/null
+++ b/test/transform/resource/after-delombok/AccessorsInAnonymousClass.java
@@ -0,0 +1,22 @@
+public class AccessorsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public String string() {
+ return this.string;
+ }
+
+ /**
+ * @return {@code this}.
+ */
+ @java.lang.SuppressWarnings("all")
+ public Inner string(final String string) {
+ this.string = string;
+ return this;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/BuilderInAnonymousClass.java b/test/transform/resource/after-delombok/BuilderInAnonymousClass.java
new file mode 100644
index 00000000..4810a0a8
--- /dev/null
+++ b/test/transform/resource/after-delombok/BuilderInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class BuilderInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java b/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java
new file mode 100644
index 00000000..7483718f
--- /dev/null
+++ b/test/transform/resource/after-delombok/ConstructorsInAnonymousClass.java
@@ -0,0 +1,34 @@
+//version 8:
+import lombok.NonNull;
+
+public class ConstructorsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ @NonNull
+ private String string2;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(final String string, @NonNull final String string2) {
+ if (string2 == null) {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string = string;
+ this.string2 = string2;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(@NonNull final String string2) {
+ if (string2 == null) {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string2 = string2;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public Inner() {
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/DataInAnonymousClass.java b/test/transform/resource/after-delombok/DataInAnonymousClass.java
new file mode 100644
index 00000000..788d7be5
--- /dev/null
+++ b/test/transform/resource/after-delombok/DataInAnonymousClass.java
@@ -0,0 +1,56 @@
+public class DataInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner() {
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public void setString(final String string) {
+ this.string = string;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof Inner;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.getString() + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java b/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java
new file mode 100644
index 00000000..6f0b5738
--- /dev/null
+++ b/test/transform/resource/after-delombok/EqualsAndHashCodeInAnonymousClass.java
@@ -0,0 +1,36 @@
+public class EqualsAndHashCodeInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ if (!other.canEqual((java.lang.Object) this)) return false;
+ final java.lang.Object this$string = this.string;
+ final java.lang.Object other$string = other.string;
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ protected boolean canEqual(final java.lang.Object other) {
+ return other instanceof Inner;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.string;
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java b/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java
new file mode 100644
index 00000000..1f7e7d7a
--- /dev/null
+++ b/test/transform/resource/after-delombok/FieldNameConstantsInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class FieldNameConstantsInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/GetterInAnonymousClass.java b/test/transform/resource/after-delombok/GetterInAnonymousClass.java
new file mode 100644
index 00000000..3c990545
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterInAnonymousClass.java
@@ -0,0 +1,13 @@
+public class GetterInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java b/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java
new file mode 100644
index 00000000..4476e463
--- /dev/null
+++ b/test/transform/resource/after-delombok/GetterLazyInAnonymousClass.java
@@ -0,0 +1,24 @@
+public class GetterLazyInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private final java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
+
+ @java.lang.SuppressWarnings({"all", "unchecked"})
+ public String getString() {
+ java.lang.Object value = this.string.get();
+ if (value == null) {
+ synchronized (this.string) {
+ value = this.string.get();
+ if (value == null) {
+ final String actualValue = "test";
+ value = actualValue == null ? this.string : actualValue;
+ this.string.set(value);
+ }
+ }
+ }
+ return (String) (value == this.string ? null : value);
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java b/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java
new file mode 100644
index 00000000..1ec25d92
--- /dev/null
+++ b/test/transform/resource/after-delombok/LoggerSlf4jInAnonymousClass.java
@@ -0,0 +1,7 @@
+public class LoggerSlf4jInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SetterInAnonymousClass.java b/test/transform/resource/after-delombok/SetterInAnonymousClass.java
new file mode 100644
index 00000000..ced2be52
--- /dev/null
+++ b/test/transform/resource/after-delombok/SetterInAnonymousClass.java
@@ -0,0 +1,13 @@
+public class SetterInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public void setString(final String string) {
+ this.string = string;
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java b/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java
new file mode 100644
index 00000000..cc654919
--- /dev/null
+++ b/test/transform/resource/after-delombok/SuperBuilderInAnonymousClass.java
@@ -0,0 +1,12 @@
+public class SuperBuilderInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class InnerParent {
+ private String string;
+ }
+
+ class InnerChild {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java b/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java
new file mode 100644
index 00000000..904487a3
--- /dev/null
+++ b/test/transform/resource/after-delombok/SynchronizedInAnonymousClass.java
@@ -0,0 +1,15 @@
+public class SynchronizedInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ @java.lang.SuppressWarnings("all")
+ private final java.lang.Object $lock = new java.lang.Object[0];
+
+ public void foo() {
+ synchronized (this.$lock) {
+ String foo = "bar";
+ }
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ToStringInAnonymousClass.java b/test/transform/resource/after-delombok/ToStringInAnonymousClass.java
new file mode 100644
index 00000000..aa3651bb
--- /dev/null
+++ b/test/transform/resource/after-delombok/ToStringInAnonymousClass.java
@@ -0,0 +1,14 @@
+public class ToStringInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.string + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java b/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java
new file mode 100644
index 00000000..3df9b559
--- /dev/null
+++ b/test/transform/resource/after-delombok/UtilityClassInAnonymousClass.java
@@ -0,0 +1,8 @@
+public class UtilityClassInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private String string;
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/ValAnonymousSubclassSelfReference.java b/test/transform/resource/after-delombok/ValAnonymousSubclassSelfReference.java
new file mode 100644
index 00000000..a1176a3c
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValAnonymousSubclassSelfReference.java
@@ -0,0 +1,17 @@
+import java.util.Map;
+import java.util.HashMap;
+
+public class ValAnonymousSubclassSelfReference {
+ public <T> void test(T arg) {
+ T d = arg;
+ Integer[] e = new Integer[1];
+ int[] f = new int[0];
+ java.util.Map<java.lang.String, Integer> g = new HashMap<String, Integer>();
+ Integer h = 0;
+ int i = 0;
+ final int j = 1;
+ final int k = 2;
+ new ValAnonymousSubclassSelfReference() {
+ };
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ValSwitchExpression.java b/test/transform/resource/after-delombok/ValSwitchExpression.java
index a8fa9b0f..ba26c137 100644
--- a/test/transform/resource/after-delombok/ValSwitchExpression.java
+++ b/test/transform/resource/after-delombok/ValSwitchExpression.java
@@ -1,9 +1,9 @@
// version 14:
public class ValSwitchExpression {
public void method(int arg) {
- final int x = switch (arg) {
+ final var x = switch (arg) {
default -> {
- final java.lang.String s = "string";
+ final var s = "string";
yield arg;
}
};
diff --git a/test/transform/resource/after-delombok/ValToNative.java b/test/transform/resource/after-delombok/ValToNative.java
new file mode 100644
index 00000000..64aff9e5
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValToNative.java
@@ -0,0 +1,15 @@
+// version 10:
+import java.io.IOException;
+import java.util.Arrays;
+
+public class ValToNative {
+ private void test() throws IOException {
+ final var intField = 1;
+ for (final var s : Arrays.asList("1")) {
+ final var s2 = s;
+ }
+ try (var in = getClass().getResourceAsStream("ValToNative.class")) {
+ final var j = in.read();
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-delombok/ValueInAnonymousClass.java b/test/transform/resource/after-delombok/ValueInAnonymousClass.java
new file mode 100644
index 00000000..5bab4093
--- /dev/null
+++ b/test/transform/resource/after-delombok/ValueInAnonymousClass.java
@@ -0,0 +1,46 @@
+public class ValueInAnonymousClass {
+ Object annonymous = new Object() {
+
+ final class Inner {
+ private final String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner(final String string) {
+ this.string = string;
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public String getString() {
+ return this.string;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public boolean equals(final java.lang.Object o) {
+ if (o == this) return true;
+ if (!(o instanceof Inner)) return false;
+ final Inner other = (Inner) o;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (this$string == null ? other$string != null : !this$string.equals(other$string)) return false;
+ return true;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = result * PRIME + ($string == null ? 43 : $string.hashCode());
+ return result;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("all")
+ public java.lang.String toString() {
+ return "Inner(string=" + this.getString() + ")";
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/WithByInAnonymousClass.java b/test/transform/resource/after-delombok/WithByInAnonymousClass.java
new file mode 100644
index 00000000..d84955b6
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithByInAnonymousClass.java
@@ -0,0 +1,17 @@
+//version 8:
+public class WithByInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private Inner(String string) {
+ }
+
+ private String string;
+
+ @java.lang.SuppressWarnings("all")
+ public Inner withStringBy(final java.util.function.Function<? super String, ? extends String> transformer) {
+ return new Inner(transformer.apply(this.string));
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-delombok/WithInAnonymousClass.java b/test/transform/resource/after-delombok/WithInAnonymousClass.java
new file mode 100644
index 00000000..02490533
--- /dev/null
+++ b/test/transform/resource/after-delombok/WithInAnonymousClass.java
@@ -0,0 +1,19 @@
+public class WithInAnonymousClass {
+ Object annonymous = new Object() {
+
+ class Inner {
+ private Inner(String string) {
+ }
+
+ private String string;
+
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
+ @java.lang.SuppressWarnings("all")
+ public Inner withString(final String string) {
+ return this.string == string ? this : new Inner(string);
+ }
+ }
+ };
+}
diff --git a/test/transform/resource/after-ecj/AccessorsInAnonymousClass.java b/test/transform/resource/after-ecj/AccessorsInAnonymousClass.java
new file mode 100644
index 00000000..34db4f2d
--- /dev/null
+++ b/test/transform/resource/after-ecj/AccessorsInAnonymousClass.java
@@ -0,0 +1,29 @@
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+public class AccessorsInAnonymousClass {
+ Object annonymous = new Object() {
+ @Getter @Setter @Accessors(fluent = true) class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") String string() {
+ return this.string;
+ }
+ /**
+ * @return {@code this}.
+ */
+ public @java.lang.SuppressWarnings("all") Inner string(final String string) {
+ this.string = string;
+ return this;
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public AccessorsInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/BuilderInAnonymousClass.java b/test/transform/resource/after-ecj/BuilderInAnonymousClass.java
new file mode 100644
index 00000000..67660822
--- /dev/null
+++ b/test/transform/resource/after-ecj/BuilderInAnonymousClass.java
@@ -0,0 +1,17 @@
+import lombok.Builder;
+public class BuilderInAnonymousClass {
+ Object annonymous = new Object() {
+ @Builder class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public BuilderInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/ConstructorsInAnonymousClass.java b/test/transform/resource/after-ecj/ConstructorsInAnonymousClass.java
new file mode 100644
index 00000000..545ab04d
--- /dev/null
+++ b/test/transform/resource/after-ecj/ConstructorsInAnonymousClass.java
@@ -0,0 +1,38 @@
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+public class ConstructorsInAnonymousClass {
+ Object annonymous = new Object() {
+ @AllArgsConstructor @RequiredArgsConstructor @NoArgsConstructor class Inner {
+ private String string;
+ private @NonNull String string2;
+ public @java.lang.SuppressWarnings("all") Inner(final String string, final @NonNull String string2) {
+ super();
+ if ((string2 == null))
+ {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string = string;
+ this.string2 = string2;
+ }
+ public @java.lang.SuppressWarnings("all") Inner(final @NonNull String string2) {
+ super();
+ if ((string2 == null))
+ {
+ throw new java.lang.NullPointerException("string2 is marked non-null but is null");
+ }
+ this.string2 = string2;
+ }
+ public @java.lang.SuppressWarnings("all") Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public ConstructorsInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/DataInAnonymousClass.java b/test/transform/resource/after-ecj/DataInAnonymousClass.java
new file mode 100644
index 00000000..c6e22f80
--- /dev/null
+++ b/test/transform/resource/after-ecj/DataInAnonymousClass.java
@@ -0,0 +1,50 @@
+import lombok.Data;
+public class DataInAnonymousClass {
+ Object annonymous = new Object() {
+ @Data class Inner {
+ private String string;
+ public @java.lang.SuppressWarnings("all") String getString() {
+ return this.string;
+ }
+ public @java.lang.SuppressWarnings("all") void setString(final String string) {
+ this.string = string;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof Inner)))
+ return false;
+ final Inner other = (Inner) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof Inner);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("Inner(string=" + this.getString()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public DataInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/EqualsAndHashCodeInAnonymousClass.java b/test/transform/resource/after-ecj/EqualsAndHashCodeInAnonymousClass.java
new file mode 100644
index 00000000..e66850bb
--- /dev/null
+++ b/test/transform/resource/after-ecj/EqualsAndHashCodeInAnonymousClass.java
@@ -0,0 +1,41 @@
+import lombok.EqualsAndHashCode;
+public class EqualsAndHashCodeInAnonymousClass {
+ Object annonymous = new Object() {
+ @EqualsAndHashCode class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof Inner)))
+ return false;
+ final Inner other = (Inner) o;
+ if ((! other.canEqual((java.lang.Object) this)))
+ return false;
+ final java.lang.Object this$string = this.string;
+ final java.lang.Object other$string = other.string;
+ if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
+ return false;
+ return true;
+ }
+ protected @java.lang.SuppressWarnings("all") boolean canEqual(final java.lang.Object other) {
+ return (other instanceof Inner);
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.string;
+ result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
+ return result;
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public EqualsAndHashCodeInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/FieldNameConstantsInAnonymousClass.java b/test/transform/resource/after-ecj/FieldNameConstantsInAnonymousClass.java
new file mode 100644
index 00000000..b04bef51
--- /dev/null
+++ b/test/transform/resource/after-ecj/FieldNameConstantsInAnonymousClass.java
@@ -0,0 +1,17 @@
+import lombok.experimental.FieldNameConstants;
+public class FieldNameConstantsInAnonymousClass {
+ Object annonymous = new Object() {
+ @FieldNameConstants class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public FieldNameConstantsInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/GetterInAnonymousClass.java b/test/transform/resource/after-ecj/GetterInAnonymousClass.java
new file mode 100644
index 00000000..30e6338d
--- /dev/null
+++ b/test/transform/resource/after-ecj/GetterInAnonymousClass.java
@@ -0,0 +1,20 @@
+import lombok.Getter;
+public class GetterInAnonymousClass {
+ Object annonymous = new Object() {
+ @Getter class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") String getString() {
+ return this.string;
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public GetterInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/GetterLazyInAnonymousClass.java b/test/transform/resource/after-ecj/GetterLazyInAnonymousClass.java
new file mode 100644
index 00000000..ab8bc599
--- /dev/null
+++ b/test/transform/resource/after-ecj/GetterLazyInAnonymousClass.java
@@ -0,0 +1,34 @@
+import lombok.Getter;
+public class GetterLazyInAnonymousClass {
+ Object annonymous = new Object() {
+ class Inner {
+ private final @Getter(lazy = true) java.util.concurrent.atomic.AtomicReference<java.lang.Object> string = new java.util.concurrent.atomic.AtomicReference<java.lang.Object>();
+ Inner() {
+ super();
+ }
+ public @java.lang.SuppressWarnings({"all", "unchecked"}) String getString() {
+ java.lang.Object value = this.string.get();
+ if ((value == null))
+ {
+ synchronized (this.string)
+ {
+ value = this.string.get();
+ if ((value == null))
+ {
+ final String actualValue = "test";
+ value = ((actualValue == null) ? this.string : actualValue);
+ this.string.set(value);
+ }
+ }
+ }
+ return (String) ((value == this.string) ? null : value);
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public GetterLazyInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/LoggerSlf4jInAnonymousClass.java b/test/transform/resource/after-ecj/LoggerSlf4jInAnonymousClass.java
new file mode 100644
index 00000000..0c78a288
--- /dev/null
+++ b/test/transform/resource/after-ecj/LoggerSlf4jInAnonymousClass.java
@@ -0,0 +1,16 @@
+import lombok.extern.slf4j.Slf4j;
+public class LoggerSlf4jInAnonymousClass {
+ Object annonymous = new Object() {
+ @Slf4j class Inner {
+ Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public LoggerSlf4jInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SetterInAnonymousClass.java b/test/transform/resource/after-ecj/SetterInAnonymousClass.java
new file mode 100644
index 00000000..fc0bf2d8
--- /dev/null
+++ b/test/transform/resource/after-ecj/SetterInAnonymousClass.java
@@ -0,0 +1,20 @@
+import lombok.Setter;
+public class SetterInAnonymousClass {
+ Object annonymous = new Object() {
+ @Setter class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") void setString(final String string) {
+ this.string = string;
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public SetterInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SuperBuilderInAnonymousClass.java b/test/transform/resource/after-ecj/SuperBuilderInAnonymousClass.java
new file mode 100644
index 00000000..238f42df
--- /dev/null
+++ b/test/transform/resource/after-ecj/SuperBuilderInAnonymousClass.java
@@ -0,0 +1,23 @@
+import lombok.experimental.SuperBuilder;
+public class SuperBuilderInAnonymousClass {
+ Object annonymous = new Object() {
+ @SuperBuilder class InnerParent {
+ private String string;
+ InnerParent() {
+ super();
+ }
+ }
+ @SuperBuilder class InnerChild {
+ private String string;
+ InnerChild() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public SuperBuilderInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/SynchronizedInAnonymousClass.java b/test/transform/resource/after-ecj/SynchronizedInAnonymousClass.java
new file mode 100644
index 00000000..77013f2f
--- /dev/null
+++ b/test/transform/resource/after-ecj/SynchronizedInAnonymousClass.java
@@ -0,0 +1,23 @@
+import lombok.Synchronized;
+public class SynchronizedInAnonymousClass {
+ Object annonymous = new Object() {
+ class Inner {
+ private final java.lang.Object $lock = new java.lang.Object[0];
+ Inner() {
+ super();
+ }
+ public @Synchronized void foo() {
+ synchronized (this.$lock)
+ {
+ String foo = "bar";
+ }
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public SynchronizedInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/ToStringInAnonymousClass.java b/test/transform/resource/after-ecj/ToStringInAnonymousClass.java
new file mode 100644
index 00000000..02ad2a88
--- /dev/null
+++ b/test/transform/resource/after-ecj/ToStringInAnonymousClass.java
@@ -0,0 +1,20 @@
+import lombok.ToString;
+public class ToStringInAnonymousClass {
+ Object annonymous = new Object() {
+ @ToString class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("Inner(string=" + this.string) + ")");
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public ToStringInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/UtilityClassInAnonymousClass.java b/test/transform/resource/after-ecj/UtilityClassInAnonymousClass.java
new file mode 100644
index 00000000..e836636d
--- /dev/null
+++ b/test/transform/resource/after-ecj/UtilityClassInAnonymousClass.java
@@ -0,0 +1,17 @@
+import lombok.experimental.UtilityClass;
+public class UtilityClassInAnonymousClass {
+ Object annonymous = new Object() {
+ @UtilityClass class Inner {
+ private String string;
+ Inner() {
+ super();
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public UtilityClassInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/ValAnonymousSubclassSelfReference.java b/test/transform/resource/after-ecj/ValAnonymousSubclassSelfReference.java
new file mode 100644
index 00000000..12b0f640
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValAnonymousSubclassSelfReference.java
@@ -0,0 +1,23 @@
+import java.util.Map;
+import java.util.HashMap;
+import lombok.val;
+public class ValAnonymousSubclassSelfReference {
+ public ValAnonymousSubclassSelfReference() {
+ super();
+ }
+ public <T>void test(T arg) {
+ T d = arg;
+ Integer[] e = new Integer[1];
+ int[] f = new int[0];
+ java.util.Map<java.lang.String, Integer> g = new HashMap<String, Integer>();
+ Integer h = 0;
+ int i = 0;
+ final @val int j = 1;
+ final @val int k = 2;
+ new ValAnonymousSubclassSelfReference() {
+ x() {
+ super();
+ }
+ };
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ValSwitchExpression.java b/test/transform/resource/after-ecj/ValSwitchExpression.java
index 59b503cb..4e848572 100644
--- a/test/transform/resource/after-ecj/ValSwitchExpression.java
+++ b/test/transform/resource/after-ecj/ValSwitchExpression.java
@@ -5,10 +5,10 @@ public class ValSwitchExpression {
super();
}
public void method(int arg) {
- final @val int x = switch (arg) {
+ final @val var x = switch (arg) {
default ->
{
- final @val java.lang.String s = "string";
+ final @val var s = "string";
yield arg;
}
};
diff --git a/test/transform/resource/after-ecj/ValToNative.java b/test/transform/resource/after-ecj/ValToNative.java
new file mode 100644
index 00000000..2c8d721c
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValToNative.java
@@ -0,0 +1,19 @@
+import java.io.IOException;
+import java.util.Arrays;
+import lombok.val;
+public class ValToNative {
+ public ValToNative() {
+ super();
+ }
+ private void test() throws IOException {
+ final @val var intField = 1;
+ for (final @val var s : Arrays.asList("1"))
+ {
+ final @val var s2 = s;
+ }
+ try (final @val var in = getClass().getResourceAsStream("ValToNative.class"))
+ {
+ final @val var j = in.read();
+ }
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/after-ecj/ValueInAnonymousClass.java b/test/transform/resource/after-ecj/ValueInAnonymousClass.java
new file mode 100644
index 00000000..49cf8fc2
--- /dev/null
+++ b/test/transform/resource/after-ecj/ValueInAnonymousClass.java
@@ -0,0 +1,43 @@
+import lombok.Value;
+public class ValueInAnonymousClass {
+ Object annonymous = new Object() {
+ final @Value class Inner {
+ private final String string;
+ public @java.lang.SuppressWarnings("all") String getString() {
+ return this.string;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") boolean equals(final java.lang.Object o) {
+ if ((o == this))
+ return true;
+ if ((! (o instanceof Inner)))
+ return false;
+ final Inner other = (Inner) o;
+ final java.lang.Object this$string = this.getString();
+ final java.lang.Object other$string = other.getString();
+ if (((this$string == null) ? (other$string != null) : (! this$string.equals(other$string))))
+ return false;
+ return true;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") int hashCode() {
+ final int PRIME = 59;
+ int result = 1;
+ final java.lang.Object $string = this.getString();
+ result = ((result * PRIME) + (($string == null) ? 43 : $string.hashCode()));
+ return result;
+ }
+ public @java.lang.Override @java.lang.SuppressWarnings("all") java.lang.String toString() {
+ return (("Inner(string=" + this.getString()) + ")");
+ }
+ public @java.lang.SuppressWarnings("all") Inner(final String string) {
+ super();
+ this.string = string;
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public ValueInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/WithByInAnonymousClass.java b/test/transform/resource/after-ecj/WithByInAnonymousClass.java
new file mode 100644
index 00000000..1bc3e80c
--- /dev/null
+++ b/test/transform/resource/after-ecj/WithByInAnonymousClass.java
@@ -0,0 +1,20 @@
+import lombok.experimental.WithBy;
+public class WithByInAnonymousClass {
+ Object annonymous = new Object() {
+ @WithBy class Inner {
+ private String string;
+ private Inner(String string) {
+ super();
+ }
+ public @java.lang.SuppressWarnings("all") Inner withStringBy(final java.util.function.Function<? super String, ? extends String> transformer) {
+ return new Inner(transformer.apply(this.string));
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public WithByInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/after-ecj/WithInAnonymousClass.java b/test/transform/resource/after-ecj/WithInAnonymousClass.java
new file mode 100644
index 00000000..fef96022
--- /dev/null
+++ b/test/transform/resource/after-ecj/WithInAnonymousClass.java
@@ -0,0 +1,23 @@
+import lombok.With;
+public class WithInAnonymousClass {
+ Object annonymous = new Object() {
+ @With class Inner {
+ private String string;
+ private Inner(String string) {
+ super();
+ }
+ /**
+ * @return a clone of this object, except with this updated property (returns {@code this} if an identical value is passed).
+ */
+ public @java.lang.SuppressWarnings("all") Inner withString(final String string) {
+ return ((this.string == string) ? this : new Inner(string));
+ }
+ }
+ x() {
+ super();
+ }
+ };
+ public WithInAnonymousClass() {
+ super();
+ }
+}
diff --git a/test/transform/resource/before/AccessorsInAnonymousClass.java b/test/transform/resource/before/AccessorsInAnonymousClass.java
new file mode 100644
index 00000000..0bbab1d6
--- /dev/null
+++ b/test/transform/resource/before/AccessorsInAnonymousClass.java
@@ -0,0 +1,14 @@
+import lombok.Getter;
+import lombok.Setter;
+import lombok.experimental.Accessors;
+
+public class AccessorsInAnonymousClass {
+ Object annonymous = new Object() {
+ @Getter
+ @Setter
+ @Accessors(fluent = true)
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/BuilderInAnonymousClass.java b/test/transform/resource/before/BuilderInAnonymousClass.java
new file mode 100644
index 00000000..8291e678
--- /dev/null
+++ b/test/transform/resource/before/BuilderInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Builder;
+
+public class BuilderInAnonymousClass {
+ Object annonymous = new Object() {
+ @Builder
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ConstructorsInAnonymousClass.java b/test/transform/resource/before/ConstructorsInAnonymousClass.java
new file mode 100644
index 00000000..a74a7f11
--- /dev/null
+++ b/test/transform/resource/before/ConstructorsInAnonymousClass.java
@@ -0,0 +1,18 @@
+//version 8:
+import lombok.AllArgsConstructor;
+import lombok.NoArgsConstructor;
+import lombok.NonNull;
+import lombok.RequiredArgsConstructor;
+
+public class ConstructorsInAnonymousClass {
+ Object annonymous = new Object() {
+ @AllArgsConstructor
+ @RequiredArgsConstructor
+ @NoArgsConstructor
+ class Inner {
+ private String string;
+ @NonNull
+ private String string2;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/DataInAnonymousClass.java b/test/transform/resource/before/DataInAnonymousClass.java
new file mode 100644
index 00000000..3de5ac0b
--- /dev/null
+++ b/test/transform/resource/before/DataInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Data;
+
+public class DataInAnonymousClass {
+ Object annonymous = new Object() {
+ @Data
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/EqualsAndHashCodeInAnonymousClass.java b/test/transform/resource/before/EqualsAndHashCodeInAnonymousClass.java
new file mode 100644
index 00000000..0f0995b6
--- /dev/null
+++ b/test/transform/resource/before/EqualsAndHashCodeInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.EqualsAndHashCode;
+
+public class EqualsAndHashCodeInAnonymousClass {
+ Object annonymous = new Object() {
+ @EqualsAndHashCode
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/FieldNameConstantsInAnonymousClass.java b/test/transform/resource/before/FieldNameConstantsInAnonymousClass.java
new file mode 100644
index 00000000..86325ce5
--- /dev/null
+++ b/test/transform/resource/before/FieldNameConstantsInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.experimental.FieldNameConstants;
+
+public class FieldNameConstantsInAnonymousClass {
+ Object annonymous = new Object() {
+ @FieldNameConstants
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/GetterInAnonymousClass.java b/test/transform/resource/before/GetterInAnonymousClass.java
new file mode 100644
index 00000000..e8195021
--- /dev/null
+++ b/test/transform/resource/before/GetterInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Getter;
+
+public class GetterInAnonymousClass {
+ Object annonymous = new Object() {
+ @Getter
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/GetterLazyInAnonymousClass.java b/test/transform/resource/before/GetterLazyInAnonymousClass.java
new file mode 100644
index 00000000..e342e636
--- /dev/null
+++ b/test/transform/resource/before/GetterLazyInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Getter;
+
+public class GetterLazyInAnonymousClass {
+ Object annonymous = new Object() {
+ class Inner {
+ @Getter(lazy = true)
+ private final String string = "test";
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/LoggerSlf4jInAnonymousClass.java b/test/transform/resource/before/LoggerSlf4jInAnonymousClass.java
new file mode 100644
index 00000000..4839c7aa
--- /dev/null
+++ b/test/transform/resource/before/LoggerSlf4jInAnonymousClass.java
@@ -0,0 +1,9 @@
+import lombok.extern.slf4j.Slf4j;
+
+public class LoggerSlf4jInAnonymousClass {
+ Object annonymous = new Object() {
+ @Slf4j
+ class Inner {
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/MixGetterVal.java b/test/transform/resource/before/MixGetterVal.java
index 3f06b1a8..4568902b 100644
--- a/test/transform/resource/before/MixGetterVal.java
+++ b/test/transform/resource/before/MixGetterVal.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.Getter;
import lombok.val;
diff --git a/test/transform/resource/before/SetterInAnonymousClass.java b/test/transform/resource/before/SetterInAnonymousClass.java
new file mode 100644
index 00000000..1b3c817b
--- /dev/null
+++ b/test/transform/resource/before/SetterInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Setter;
+
+public class SetterInAnonymousClass {
+ Object annonymous = new Object() {
+ @Setter
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/SuperBuilderInAnonymousClass.java b/test/transform/resource/before/SuperBuilderInAnonymousClass.java
new file mode 100644
index 00000000..bff871aa
--- /dev/null
+++ b/test/transform/resource/before/SuperBuilderInAnonymousClass.java
@@ -0,0 +1,15 @@
+import lombok.experimental.SuperBuilder;
+
+public class SuperBuilderInAnonymousClass {
+ Object annonymous = new Object() {
+ @SuperBuilder
+ class InnerParent {
+ private String string;
+ }
+
+ @SuperBuilder
+ class InnerChild {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/SynchronizedInAnonymousClass.java b/test/transform/resource/before/SynchronizedInAnonymousClass.java
new file mode 100644
index 00000000..11c623ce
--- /dev/null
+++ b/test/transform/resource/before/SynchronizedInAnonymousClass.java
@@ -0,0 +1,12 @@
+import lombok.Synchronized;
+
+public class SynchronizedInAnonymousClass {
+ Object annonymous = new Object() {
+ class Inner {
+ @Synchronized
+ public void foo() {
+ String foo = "bar";
+ }
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ToStringInAnonymousClass.java b/test/transform/resource/before/ToStringInAnonymousClass.java
new file mode 100644
index 00000000..87a7a6c1
--- /dev/null
+++ b/test/transform/resource/before/ToStringInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.ToString;
+
+public class ToStringInAnonymousClass {
+ Object annonymous = new Object() {
+ @ToString
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/TrickyTypeResolution.java b/test/transform/resource/before/TrickyTypeResolution.java
index 94d97fe0..7f3866ee 100644
--- a/test/transform/resource/before/TrickyTypeResolution.java
+++ b/test/transform/resource/before/TrickyTypeResolution.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.*;
class TrickyDoNothing {
@interface Getter {}
diff --git a/test/transform/resource/before/UtilityClassInAnonymousClass.java b/test/transform/resource/before/UtilityClassInAnonymousClass.java
new file mode 100644
index 00000000..41757502
--- /dev/null
+++ b/test/transform/resource/before/UtilityClassInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.experimental.UtilityClass;
+
+public class UtilityClassInAnonymousClass {
+ Object annonymous = new Object() {
+ @UtilityClass
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ValAnonymousSubclassSelfReference.java b/test/transform/resource/before/ValAnonymousSubclassSelfReference.java
new file mode 100644
index 00000000..e7c30c84
--- /dev/null
+++ b/test/transform/resource/before/ValAnonymousSubclassSelfReference.java
@@ -0,0 +1,21 @@
+// issue 2420: to trigger the problem 2 var/val, at least one normal variable and a anonymous self reference is required
+import java.util.Map;
+import java.util.HashMap;
+
+import lombok.val;
+
+public class ValAnonymousSubclassSelfReference {
+ public <T> void test(T arg) {
+ T d = arg;
+ Integer[] e = new Integer[1];
+ int[] f = new int[0];
+ java.util.Map<java.lang.String, Integer> g = new HashMap<String, Integer>();
+ Integer h = 0;
+ int i = 0;
+
+ val j = 1;
+ val k = 2;
+
+ new ValAnonymousSubclassSelfReference() { };
+ }
+} \ No newline at end of file
diff --git a/test/transform/resource/before/ValAnonymousSubclassWithGenerics.java b/test/transform/resource/before/ValAnonymousSubclassWithGenerics.java
index c0f8157a..a434ba9d 100644
--- a/test/transform/resource/before/ValAnonymousSubclassWithGenerics.java
+++ b/test/transform/resource/before/ValAnonymousSubclassWithGenerics.java
@@ -1,3 +1,4 @@
+// version :9
// issue 205: val inside anonymous inner classes is a bit tricky in javac, this test ensures we don't break it.
import java.util.*;
import lombok.val;
diff --git a/test/transform/resource/before/ValComplex.java b/test/transform/resource/before/ValComplex.java
index e20124a2..f1898cfd 100644
--- a/test/transform/resource/before/ValComplex.java
+++ b/test/transform/resource/before/ValComplex.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValComplex {
diff --git a/test/transform/resource/before/ValDefault.java b/test/transform/resource/before/ValDefault.java
index 75124c3c..ded4b074 100644
--- a/test/transform/resource/before/ValDefault.java
+++ b/test/transform/resource/before/ValDefault.java
@@ -1,4 +1,4 @@
-// version 8:
+// version 8:9
interface ValDefault {
int size();
diff --git a/test/transform/resource/before/ValDelegateMethodReference.java b/test/transform/resource/before/ValDelegateMethodReference.java
index 3d1f082c..8cfc2c33 100644
--- a/test/transform/resource/before/ValDelegateMethodReference.java
+++ b/test/transform/resource/before/ValDelegateMethodReference.java
@@ -1,4 +1,4 @@
-//version 8:
+//version 8:9
//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.Getter;
import lombok.Setter;
diff --git a/test/transform/resource/before/ValErrors.java b/test/transform/resource/before/ValErrors.java
index 87383719..290a1f72 100644
--- a/test/transform/resource/before/ValErrors.java
+++ b/test/transform/resource/before/ValErrors.java
@@ -1,3 +1,4 @@
+// version :9
// unchanged
import lombok.val;
diff --git a/test/transform/resource/before/ValFinal.java b/test/transform/resource/before/ValFinal.java
index 3c5af366..293c9bce 100644
--- a/test/transform/resource/before/ValFinal.java
+++ b/test/transform/resource/before/ValFinal.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValFinal {
public void test() {
diff --git a/test/transform/resource/before/ValInBasicFor.java b/test/transform/resource/before/ValInBasicFor.java
index a109bcd3..b137f0d7 100644
--- a/test/transform/resource/before/ValInBasicFor.java
+++ b/test/transform/resource/before/ValInBasicFor.java
@@ -1,3 +1,4 @@
+// version :9
// unchanged
import lombok.val;
diff --git a/test/transform/resource/before/ValInFor.java b/test/transform/resource/before/ValInFor.java
index 35332b34..f2c50139 100644
--- a/test/transform/resource/before/ValInFor.java
+++ b/test/transform/resource/before/ValInFor.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValInFor {
diff --git a/test/transform/resource/before/ValInLambda.java b/test/transform/resource/before/ValInLambda.java
index 6750d045..a13c79d2 100644
--- a/test/transform/resource/before/ValInLambda.java
+++ b/test/transform/resource/before/ValInLambda.java
@@ -1,4 +1,4 @@
-// version 8:
+// version 8:9
import java.util.function.Function;
import java.util.function.Supplier;
diff --git a/test/transform/resource/before/ValInMultiDeclaration.java b/test/transform/resource/before/ValInMultiDeclaration.java
index 1c333ebb..0f4e604b 100644
--- a/test/transform/resource/before/ValInMultiDeclaration.java
+++ b/test/transform/resource/before/ValInMultiDeclaration.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValInMultiDeclaration {
public void test() {
diff --git a/test/transform/resource/before/ValInTryWithResources.java b/test/transform/resource/before/ValInTryWithResources.java
index a7820062..5c885f79 100644
--- a/test/transform/resource/before/ValInTryWithResources.java
+++ b/test/transform/resource/before/ValInTryWithResources.java
@@ -1,4 +1,4 @@
-//version 7:
+//version 7:9
import lombok.val;
import java.io.IOException;
diff --git a/test/transform/resource/before/ValLambda.java b/test/transform/resource/before/ValLambda.java
index e956bcd3..8f55d222 100644
--- a/test/transform/resource/before/ValLambda.java
+++ b/test/transform/resource/before/ValLambda.java
@@ -1,4 +1,4 @@
-// version 8:
+// version 8:9
import java.io.Serializable;
class ValLambda {
diff --git a/test/transform/resource/before/ValLessSimple.java b/test/transform/resource/before/ValLessSimple.java
index b81cc22c..1ed738cc 100644
--- a/test/transform/resource/before/ValLessSimple.java
+++ b/test/transform/resource/before/ValLessSimple.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValLessSimple {
diff --git a/test/transform/resource/before/ValLub.java b/test/transform/resource/before/ValLub.java
index 509a4f8b..e3b55950 100644
--- a/test/transform/resource/before/ValLub.java
+++ b/test/transform/resource/before/ValLub.java
@@ -1,3 +1,4 @@
+// version :9
class ValLub {
public void easyLub() {
java.util.Map<String, Number> m = java.util.Collections.emptyMap();
diff --git a/test/transform/resource/before/ValNullInit.java b/test/transform/resource/before/ValNullInit.java
index 649bc0cd..c1610af3 100644
--- a/test/transform/resource/before/ValNullInit.java
+++ b/test/transform/resource/before/ValNullInit.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
class ValNullInit {
diff --git a/test/transform/resource/before/ValOutersWithGenerics.java b/test/transform/resource/before/ValOutersWithGenerics.java
index 1b29d37c..99b71735 100644
--- a/test/transform/resource/before/ValOutersWithGenerics.java
+++ b/test/transform/resource/before/ValOutersWithGenerics.java
@@ -1,3 +1,4 @@
+// version :9
import java.util.*;
import lombok.val;
diff --git a/test/transform/resource/before/ValRawType.java b/test/transform/resource/before/ValRawType.java
index 3ef8527e..fa47c536 100644
--- a/test/transform/resource/before/ValRawType.java
+++ b/test/transform/resource/before/ValRawType.java
@@ -1,3 +1,4 @@
+// version :9
import java.util.List;
import lombok.val;
diff --git a/test/transform/resource/before/ValSimple.java b/test/transform/resource/before/ValSimple.java
index 04763be2..5d1911da 100644
--- a/test/transform/resource/before/ValSimple.java
+++ b/test/transform/resource/before/ValSimple.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValSimple {
diff --git a/test/transform/resource/before/ValToNative.java b/test/transform/resource/before/ValToNative.java
new file mode 100644
index 00000000..3b4e6fa8
--- /dev/null
+++ b/test/transform/resource/before/ValToNative.java
@@ -0,0 +1,19 @@
+// version 10:
+import java.io.IOException;
+import java.util.Arrays;
+
+import lombok.val;
+
+public class ValToNative {
+ private void test() throws IOException {
+ val intField = 1;
+
+ for (val s : Arrays.asList("1")) {
+ val s2 = s;
+ }
+
+ try (val in = getClass().getResourceAsStream("ValToNative.class")) {
+ val j = in.read();
+ }
+ }
+}
diff --git a/test/transform/resource/before/ValWeirdTypes.java b/test/transform/resource/before/ValWeirdTypes.java
index f62feca6..710e236b 100644
--- a/test/transform/resource/before/ValWeirdTypes.java
+++ b/test/transform/resource/before/ValWeirdTypes.java
@@ -1,4 +1,4 @@
-// version 8: In java6/7, lub types worked differently, so, the `arraysAsList` method has a slightly different inferred type there.
+// version 8:9 In java6/7, lub types worked differently, so, the `arraysAsList` method has a slightly different inferred type there.
import java.math.BigDecimal;
import java.util.*;
import lombok.val;
diff --git a/test/transform/resource/before/ValWithLabel.java b/test/transform/resource/before/ValWithLabel.java
index f7c3402a..9e15f937 100644
--- a/test/transform/resource/before/ValWithLabel.java
+++ b/test/transform/resource/before/ValWithLabel.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValWithLabel {
diff --git a/test/transform/resource/before/ValWithLocalClasses.java b/test/transform/resource/before/ValWithLocalClasses.java
index 572a1e7d..0d145aa9 100644
--- a/test/transform/resource/before/ValWithLocalClasses.java
+++ b/test/transform/resource/before/ValWithLocalClasses.java
@@ -1,3 +1,4 @@
+// version :9
//issue 694: In javac, resolving the RHS (which is what val does) can cause an entire class to be resolved, breaking all usage of val inside that class. This tests that we handle that better.
class ValWithLocalClasses1 {
{
diff --git a/test/transform/resource/before/ValWithSelfRefGenerics.java b/test/transform/resource/before/ValWithSelfRefGenerics.java
index d0532606..fdb30d32 100644
--- a/test/transform/resource/before/ValWithSelfRefGenerics.java
+++ b/test/transform/resource/before/ValWithSelfRefGenerics.java
@@ -1,3 +1,4 @@
+// version :9
import lombok.val;
public class ValWithSelfRefGenerics {
public void run(Thing<? extends Comparable<?>> thing, Thing<?> thing2, java.util.List<? extends Number> z) {
diff --git a/test/transform/resource/before/ValueInAnonymousClass.java b/test/transform/resource/before/ValueInAnonymousClass.java
new file mode 100644
index 00000000..c0bde2ab
--- /dev/null
+++ b/test/transform/resource/before/ValueInAnonymousClass.java
@@ -0,0 +1,10 @@
+import lombok.Value;
+
+public class ValueInAnonymousClass {
+ Object annonymous = new Object() {
+ @Value
+ class Inner {
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/WithByInAnonymousClass.java b/test/transform/resource/before/WithByInAnonymousClass.java
new file mode 100644
index 00000000..afed6adf
--- /dev/null
+++ b/test/transform/resource/before/WithByInAnonymousClass.java
@@ -0,0 +1,13 @@
+//version 8:
+import lombok.experimental.WithBy;
+
+public class WithByInAnonymousClass {
+ Object annonymous = new Object() {
+ @WithBy
+ class Inner {
+ private Inner(String string) { }
+
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/before/WithInAnonymousClass.java b/test/transform/resource/before/WithInAnonymousClass.java
new file mode 100644
index 00000000..daf1bce5
--- /dev/null
+++ b/test/transform/resource/before/WithInAnonymousClass.java
@@ -0,0 +1,12 @@
+import lombok.With;
+
+public class WithInAnonymousClass {
+ Object annonymous = new Object() {
+ @With
+ class Inner {
+ private Inner(String string) { }
+
+ private String string;
+ }
+ };
+} \ No newline at end of file
diff --git a/test/transform/resource/messages-delombok/BuilderInAnonymousClass.java.messages b/test/transform/resource/messages-delombok/BuilderInAnonymousClass.java.messages
new file mode 100644
index 00000000..7607e734
--- /dev/null
+++ b/test/transform/resource/messages-delombok/BuilderInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @Builder is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-delombok/FieldNameConstantsInAnonymousClass.java.messages b/test/transform/resource/messages-delombok/FieldNameConstantsInAnonymousClass.java.messages
new file mode 100644
index 00000000..b9d4887f
--- /dev/null
+++ b/test/transform/resource/messages-delombok/FieldNameConstantsInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @FieldNameConstants is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-delombok/LoggerSlf4jInAnonymousClass.java.messages b/test/transform/resource/messages-delombok/LoggerSlf4jInAnonymousClass.java.messages
new file mode 100644
index 00000000..d4da9f99
--- /dev/null
+++ b/test/transform/resource/messages-delombok/LoggerSlf4jInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @Slf4j is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-delombok/SuperBuilderInAnonymousClass.java.messages b/test/transform/resource/messages-delombok/SuperBuilderInAnonymousClass.java.messages
new file mode 100644
index 00000000..f0cf3243
--- /dev/null
+++ b/test/transform/resource/messages-delombok/SuperBuilderInAnonymousClass.java.messages
@@ -0,0 +1,2 @@
+5 @SuperBuilder is not supported on non-static nested classes.
+10 @SuperBuilder is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-delombok/UtilityClassInAnonymousClass.java.messages b/test/transform/resource/messages-delombok/UtilityClassInAnonymousClass.java.messages
new file mode 100644
index 00000000..8884e02d
--- /dev/null
+++ b/test/transform/resource/messages-delombok/UtilityClassInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @UtilityClass automatically makes the class static, however, this class cannot be made static.
diff --git a/test/transform/resource/messages-ecj/BuilderInAnonymousClass.java.messages b/test/transform/resource/messages-ecj/BuilderInAnonymousClass.java.messages
new file mode 100644
index 00000000..7607e734
--- /dev/null
+++ b/test/transform/resource/messages-ecj/BuilderInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @Builder is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-ecj/FieldNameConstantsInAnonymousClass.java.messages b/test/transform/resource/messages-ecj/FieldNameConstantsInAnonymousClass.java.messages
new file mode 100644
index 00000000..b9d4887f
--- /dev/null
+++ b/test/transform/resource/messages-ecj/FieldNameConstantsInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @FieldNameConstants is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-ecj/LoggerSlf4jInAnonymousClass.java.messages b/test/transform/resource/messages-ecj/LoggerSlf4jInAnonymousClass.java.messages
new file mode 100644
index 00000000..d4da9f99
--- /dev/null
+++ b/test/transform/resource/messages-ecj/LoggerSlf4jInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @Slf4j is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-ecj/SuperBuilderInAnonymousClass.java.messages b/test/transform/resource/messages-ecj/SuperBuilderInAnonymousClass.java.messages
new file mode 100644
index 00000000..f0cf3243
--- /dev/null
+++ b/test/transform/resource/messages-ecj/SuperBuilderInAnonymousClass.java.messages
@@ -0,0 +1,2 @@
+5 @SuperBuilder is not supported on non-static nested classes.
+10 @SuperBuilder is not supported on non-static nested classes.
diff --git a/test/transform/resource/messages-ecj/UtilityClassInAnonymousClass.java.messages b/test/transform/resource/messages-ecj/UtilityClassInAnonymousClass.java.messages
new file mode 100644
index 00000000..8884e02d
--- /dev/null
+++ b/test/transform/resource/messages-ecj/UtilityClassInAnonymousClass.java.messages
@@ -0,0 +1 @@
+5 @UtilityClass automatically makes the class static, however, this class cannot be made static.
diff --git a/website/templates/features/val.html b/website/templates/features/val.html
index 32a8ffdf..1b137c65 100644
--- a/website/templates/features/val.html
+++ b/website/templates/features/val.html
@@ -5,6 +5,9 @@
<p>
<code>val</code> was introduced in lombok 0.10.
</p>
+ <p>
+ <em>NEW in Lombok 1.18.22: </em><code>val</code> gets replaced with <code>final var</code>.
+ </p>
</@f.history>
<@f.overview>
<p>