Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ jobs:
- eclipse-oxygen
- eclipse-202006
- eclipse-202006-jdk8
- eclipse-202403
- eclipse-202503
- eclipse-I-build
- eclipse-oxygen-full
- eclipse-202403-full
- eclipse-202503-full
Expand Down
2 changes: 2 additions & 0 deletions buildScripts/setup.ant.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ This buildfile is part of projectlombok.org. It sets up the build itself.
<!-- osgi.extender dependecies -->
<arg value="osgi.bundle:org.apache.felix.scr" />
<arg value="osgi.bundle:org.apache.aries.spifly.dynamic.bundle" />
<!-- Unresolvable until we add property based dependency resolution -->
<arg value="osgi.bundle:org.eclipse.swt.svg" />
<!-- Real dependencies -->
<arg value="osgi.bundle:org.eclipse.jdt.core" />
<arg value="osgi.bundle:org.eclipse.jdt.ui" />
Expand Down
37 changes: 30 additions & 7 deletions src/core/lombok/eclipse/EclipseAST.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2021 The Project Lombok Authors.
* Copyright (C) 2009-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -40,6 +40,7 @@
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.ast.ASTNode;
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
import org.eclipse.jdt.internal.compiler.ast.Annotation;
import org.eclipse.jdt.internal.compiler.ast.Argument;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
Expand Down Expand Up @@ -354,7 +355,7 @@ public static boolean isComplete(CompilationUnitDeclaration unit) {
case TYPE:
return buildType((TypeDeclaration) node);
case FIELD:
return buildField((FieldDeclaration) node, null);
return buildField((FieldDeclaration) node);
case INITIALIZER:
return buildInitializer((Initializer) node);
case METHOD:
Expand Down Expand Up @@ -393,17 +394,38 @@ private List<EclipseNode> buildTypes(TypeDeclaration[] children) {
private EclipseNode buildType(TypeDeclaration type) {
if (setAndGetAsHandled(type)) return null;
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
childNodes.addAll(buildFields(type.fields, getRecordFieldAnnotations(type)));
childNodes.addAll(buildRecordComponents(getRecordComponents(type)));
childNodes.addAll(buildFields(type.fields));
childNodes.addAll(buildTypes(type.memberTypes));
childNodes.addAll(buildMethods(type.methods));
childNodes.addAll(buildAnnotations(type.annotations, false));
return putInMap(new EclipseNode(this, type, childNodes, Kind.TYPE));
}

private Collection<EclipseNode> buildFields(FieldDeclaration[] children, Annotation[][] annotations) {
private Collection<EclipseNode> buildRecordComponents(AbstractVariableDeclaration[] children) {
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
if (children != null) for (int i = 0; i < children.length; i++) {
addIfNotNull(childNodes, buildField(children[i], annotations[i]));
addIfNotNull(childNodes, buildRecordComponent(children[i]));
}
return childNodes;
}

private EclipseNode buildRecordComponent(AbstractVariableDeclaration field) {
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
addIfNotNull(childNodes, buildTypeUse(field.type));
addIfNotNull(childNodes, buildStatement(field.initialization));
childNodes.addAll(buildAnnotations(field.annotations, true));
FieldDeclaration fieldDeclaration = new FieldDeclaration(field.name, field.sourceStart, field.sourceEnd);
fieldDeclaration.type = field.type;
fieldDeclaration.modifiers = field.modifiers | Eclipse.AccRecord;
fieldDeclaration.annotations = field.annotations;
return putInMap(new EclipseNode(this, fieldDeclaration, childNodes, Kind.FIELD));
}

private Collection<EclipseNode> buildFields(FieldDeclaration[] children) {
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
if (children != null) for (int i = 0; i < children.length; i++) {
addIfNotNull(childNodes, buildField(children[i]));
}
return childNodes;
}
Expand All @@ -414,13 +436,14 @@ private static <T> List<T> singleton(T item) {
return list;
}

private EclipseNode buildField(FieldDeclaration field, Annotation[] annotations) {
private EclipseNode buildField(FieldDeclaration field) {
if (field instanceof Initializer) return buildInitializer((Initializer) field);
if (setAndGetAsHandled(field)) return null;
if (isRecordField(field)) return null;
List<EclipseNode> childNodes = new ArrayList<EclipseNode>();
addIfNotNull(childNodes, buildTypeUse(field.type));
addIfNotNull(childNodes, buildStatement(field.initialization));
childNodes.addAll(buildAnnotations(annotations != null ? annotations : field.annotations, true));
childNodes.addAll(buildAnnotations(field.annotations, true));
return putInMap(new EclipseNode(this, field, childNodes, Kind.FIELD));
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/lombok/eclipse/handlers/HandleLockedUtil.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2024 The Project Lombok Authors.
* Copyright (C) 2024-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -87,6 +87,8 @@ public static void preHandle(String annotationValue, char[][] lockTypeClass, cha
if (methodNode == null || methodNode.getKind() != AST.Kind.METHOD || !(methodNode.get() instanceof MethodDeclaration)) return;
MethodDeclaration method = (MethodDeclaration) methodNode.get();
if (method.isAbstract()) return;
EclipseNode typeNode = upToTypeNode(annotationNode);
if (isRecord(typeNode)) return;

createLockField(annotationValue, annotationNode, lockTypeClass, lockImplClass, new AtomicBoolean(method.isStatic()), false);
}
Expand Down
23 changes: 17 additions & 6 deletions src/core/lombok/eclipse/handlers/HandleNonNull.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013-2021 The Project Lombok Authors.
* Copyright (C) 2013-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -168,10 +168,15 @@ private EclipseNode addCompactConstructorIfNeeded(EclipseNode typeNode, EclipseN
}
}
if (posToInsert == -1) {
AbstractMethodDeclaration[] na = new AbstractMethodDeclaration[td.methods.length + 1];
posToInsert = td.methods.length;
System.arraycopy(td.methods, 0, na, 0, posToInsert);
td.methods = na;
if (td.methods == null) {
td.methods = new AbstractMethodDeclaration[1];
posToInsert = 0;
} else {
posToInsert = td.methods.length;
AbstractMethodDeclaration[] na = new AbstractMethodDeclaration[posToInsert + 1];
System.arraycopy(td.methods, 0, na, 0, posToInsert);
td.methods = na;
}
}

ConstructorDeclaration cd = new ConstructorDeclaration(((CompilationUnitDeclaration) typeNode.top().get()).compilationResult);
Expand All @@ -186,8 +191,9 @@ private EclipseNode addCompactConstructorIfNeeded(EclipseNode typeNode, EclipseN

for (int i = 0; i < cd.arguments.length; i++) {
FieldDeclaration cmp = recordComponents.get(i);
cd.arguments[i] = new Argument(cmp.name, cmp.sourceStart, cmp.type, 0);
cd.arguments[i] = new Argument(cmp.name, cmp.sourceStart, cmp.type, cmp.modifiers);
cd.arguments[i].bits = ASTNode.IsArgument | ASTNode.IgnoreRawTypeCheck | ASTNode.IsReachable;
cd.arguments[i].annotations = cmp.annotations;
FieldReference lhs = new FieldReference(cmp.name, 0);
lhs.receiver = new ThisReference(0, 0);
SingleNameReference rhs = new SingleNameReference(cmp.name, 0);
Expand Down Expand Up @@ -304,6 +310,11 @@ private void handle0(Annotation ast, EclipseNode annotationNode, boolean force)
return;
}

if ((param.modifiers & AccRecord) != 0) {
addNullCheckIfNeeded(declaration, param, annotationNode);
node.up().rebuild();
}

if (!force && isGenerated(declaration)) return;

if (declaration.isAbstract()) {
Expand Down
4 changes: 3 additions & 1 deletion src/core/lombok/eclipse/handlers/HandleSynchronized.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2024 The Project Lombok Authors.
* Copyright (C) 2009-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -69,6 +69,8 @@ public class HandleSynchronized extends EclipseAnnotationHandler<Synchronized> {
if (methodNode == null || methodNode.getKind() != Kind.METHOD || !(methodNode.get() instanceof MethodDeclaration)) return;
MethodDeclaration method = (MethodDeclaration) methodNode.get();
if (method.isAbstract()) return;
EclipseNode typeNode = upToTypeNode(annotationNode);
if (isRecord(typeNode)) return;

createLockField(annotation, annotationNode, new boolean[] {method.isStatic()}, false);

Expand Down
21 changes: 19 additions & 2 deletions src/eclipseAgent/lombok/eclipse/agent/EclipsePatcher.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009-2024 The Project Lombok Authors.
* Copyright (C) 2009-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -333,7 +333,7 @@ private static void patchDomAstReparseIssues(ScriptManager sm) {
.transplant()
.build());

sm.addScriptIfComplexWitness(new String[][] {OSGI_TYPES, new String[] {"org/eclipse/jdt/internal/compiler/parser/TerminalToken"}}, ScriptBuilder.replaceMethodCall()
sm.addScriptIfWitness(OSGI_TYPES, ScriptBuilder.replaceMethodCall()
.target(new MethodTarget("org.eclipse.jdt.internal.core.dom.rewrite.ASTRewriteAnalyzer", "visit"))
.methodToReplace(new Hook("org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "getTokenEndOffset", "int", "org.eclipse.jdt.internal.compiler.parser.TerminalToken", "int"))
.replacementMethod(new Hook("lombok.launch.PatchFixesHider$PatchFixes", "getTokenEndOffsetFixed", "int", "org.eclipse.jdt.internal.core.dom.rewrite.TokenScanner", "java.lang.Object", "int", "java.lang.Object"))
Expand Down Expand Up @@ -1156,6 +1156,23 @@ private static void patchForTests(ScriptManager sm) {
.request(StackRequest.THIS, StackRequest.PARAM2)
.transplant()
.build());

// Remove implicit record fields in tests
sm.addScriptIfWitness(ECLIPSE_TEST_CLASSES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.ast.FieldDeclaration", "print", "java.lang.StringBuilder", "int", "java.lang.StringBuilder"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "isRecordComponent", "boolean", "org.eclipse.jdt.internal.compiler.ast.FieldDeclaration", "java.lang.Object"))
.valueMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "returnStringBuilder", "java.lang.StringBuilder", "java.lang.Object", "java.lang.StringBuilder"))
.request(StackRequest.THIS, StackRequest.PARAM2)
.transplant()
.build());

sm.addScriptIfWitness(ECLIPSE_TEST_CLASSES, ScriptBuilder.exitEarly()
.target(new MethodTarget("org.eclipse.jdt.internal.compiler.ast.FieldDeclaration", "print", "java.lang.StringBuffer", "int", "java.lang.StringBuffer"))
.decisionMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "isRecordComponent", "boolean", "org.eclipse.jdt.internal.compiler.ast.FieldDeclaration", "java.lang.Object"))
.valueMethod(new Hook("lombok.launch.PatchFixesHider$Tests", "returnStringBuffer", "java.lang.StringBuffer", "java.lang.Object", "java.lang.StringBuffer"))
.request(StackRequest.THIS, StackRequest.PARAM2)
.transplant()
.build());
}

}
6 changes: 5 additions & 1 deletion src/eclipseAgent/lombok/launch/PatchFixesHider.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010-2024 The Project Lombok Authors.
* Copyright (C) 2010-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -1117,6 +1117,10 @@ public static boolean isImplicitCanonicalConstructor(AbstractMethodDeclaration m
return (method.bits & IsCanonicalConstructor) != 0 && (method.bits & IsImplicit) != 0;
}

public static boolean isRecordComponent(FieldDeclaration field, Object parameter) {
return (field.modifiers & AccRecord) != 0;
}

public static StringBuffer returnStringBuffer(Object p1, StringBuffer buffer) {
return buffer;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 The Project Lombok Authors.
* Copyright (C) 2022-2025 The Project Lombok Authors.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -51,6 +51,7 @@ public static void main(String[] args) throws Exception {
String updateSiteUrl = args[2];
boolean resolveDependencies = Boolean.parseBoolean(args[3]);
List<String> bundles = Arrays.asList(Arrays.copyOfRange(args, 4, args.length));
boolean isCi = "true".equalsIgnoreCase(System.getenv("CI"));

UpdateSite updateSite = new UpdateSite();
updateSite.read(updateSiteUrl);
Expand All @@ -69,14 +70,16 @@ public static void main(String[] args) throws Exception {
// Download artifact
downloadFile(artifact, pluginSource, pluginTarget);

// Download artifact source
int index = artifact.lastIndexOf("_");
String source = artifact.substring(0, index) + ".source" + artifact.substring(index);
try {
downloadFile(source, pluginSource, pluginTarget);
} catch (Exception e) {
// It's just the source; sometimes these aren't present (specifically, `org.eclipse.swt` doesn't currently appear to have the sources, at least not using the `_sources` naming scheme). Don't fail, just skip them.
System.out.println("[failed]");
// Download artifact source for local development
if (!isCi) {
int index = artifact.lastIndexOf("_");
String source = artifact.substring(0, index) + ".source" + artifact.substring(index);
try {
downloadFile(source, pluginSource, pluginTarget);
} catch (Exception e) {
// It's just the source; sometimes these aren't present (specifically, `org.eclipse.swt` doesn't currently appear to have the sources, at least not using the `_sources` naming scheme). Don't fail, just skip them.
System.out.println("[failed]");
}
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/BuilderOnNestedRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ public record BuilderOnNestedRecord(T t)<T> {
return (("BuilderOnNestedRecord.Nested.NestedBuilder(a=" + this.a) + ")");
}
}
/* Implicit */ private final String a;
public static @java.lang.SuppressWarnings("all") @lombok.Generated BuilderOnNestedRecord.Nested.NestedBuilder builder() {
return new BuilderOnNestedRecord.Nested.NestedBuilder();
}
}
/* Implicit */ private final T t;
}
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/BuilderSimpleOnRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
return (((("BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder(l=" + this.l) + ", a=") + this.a) + ")");
}
}
/* Implicit */ private final List<T> l;
/* Implicit */ private final String a;
protected static @java.lang.SuppressWarnings("all") @lombok.Generated <T>BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder<T> builder() {
return new BuilderSimpleOnRecord.BuilderSimpleOnRecordBuilder<T>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@
return (((((("BuilderSingularOnRecord.BuilderSingularOnRecordBuilder(children=" + this.children) + ", scarves=") + this.scarves) + ", rawList=") + this.rawList) + ")");
}
}
/* Implicit */ private final List<T> children;
/* Implicit */ private final Collection<? extends Number> scarves;
/* Implicit */ private final List rawList;
public static @java.lang.SuppressWarnings("all") @lombok.Generated <T>BuilderSingularOnRecord.BuilderSingularOnRecordBuilder<T> builder() {
return new BuilderSingularOnRecord.BuilderSingularOnRecordBuilder<T>();
}
Expand Down
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/ConstructorsOnRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@
import lombok.NoArgsConstructor;
import lombok.RequiredArgsConstructor;
public @AllArgsConstructor @RequiredArgsConstructor @NoArgsConstructor record ConstructorsOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/DataOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// version 14:
import lombok.Data;
public @Data record DataOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
1 change: 0 additions & 1 deletion test/transform/resource/after-ecj/DelegateOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// version 14:
import lombok.experimental.Delegate;
record DelegateOnRecord(Runnable runnable) {
/* Implicit */ private final Runnable runnable;
public @java.lang.SuppressWarnings("all") @lombok.Generated void run() {
this.runnable.run();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// version 14:
import lombok.EqualsAndHashCode;
public @EqualsAndHashCode record EqualsAndHashCodeOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/FieldDefaultsOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// version 14:
public @lombok.experimental.FieldDefaults(makeFinal = true) record FieldDefaultsOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// version 14:
public record FieldDefaultsViaConfigOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
super();
}
}
/* Implicit */ private final String iAmADvdPlayer;
/* Implicit */ private final int $skipMe;
/* Implicit */ private final int andMe;
/* Implicit */ private final String butPrintMePlease;
static double skipMeToo;
<clinit>() {
}
Expand Down
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/GetterOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// version 14:
import lombok.Getter;
public @Getter record GetterOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/JacksonizedOnRecord.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@
return (((("JacksonizedOnRecord.JacksonizedOnRecordBuilder(string=" + this.string) + ", values=") + this.values) + ")");
}
}
/* Implicit */ private final String string;
/* Implicit */ private final List<String> values;
public static @java.lang.SuppressWarnings("all") @lombok.Generated JacksonizedOnRecord.JacksonizedOnRecordBuilder builder() {
return new JacksonizedOnRecord.JacksonizedOnRecordBuilder();
}
Expand Down
3 changes: 0 additions & 3 deletions test/transform/resource/after-ecj/LockedInRecord.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import lombok.Locked;
public record LockedInRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
private final @java.lang.SuppressWarnings("all") @lombok.Generated java.util.concurrent.locks.Lock $lock = new java.util.concurrent.locks.ReentrantLock();
public @Locked void foo() {
String foo = "bar";
}
Expand Down
2 changes: 0 additions & 2 deletions test/transform/resource/after-ecj/LoggerConfigOnRecord.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// version 14:
import lombok.extern.slf4j.Slf4j;
public @Slf4j record LoggerConfigOnRecord(String a, String b) {
/* Implicit */ private final String a;
/* Implicit */ private final String b;
}
Loading
Loading