Skip to content

Commit d62b2d5

Browse files
committed
Merge branch 'master' into cachescrubber-gh-3950
# Conflicts: # src/core/lombok/eclipse/handlers/HandleJacksonized.java # src/core/lombok/javac/handlers/HandleJacksonized.java
2 parents 25a6066 + f49f0fe commit d62b2d5

56 files changed

Lines changed: 377 additions & 364 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ant.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,10 @@ jobs:
150150
needs: build
151151
strategy:
152152
matrix:
153-
jdk: [8, 11, 17, 21, 23]
153+
jdk: [8, 11, 17, 21, 25]
154154
tool:
155155
- {name: "maven", cmd: "mvn compile"}
156-
- {name: "gradle", cmd: "gradle assemble"}
156+
- {name: "gradle", cmd: "gradle assemble", buildArgs: {"25": "--build-arg gradle=9.1.0"}}
157157
- {name: "ant", cmd: "ant dist"}
158158
- {name: "bazel", cmd: "bazel build //:ProjectRunner"}
159159
fail-fast: false
@@ -170,7 +170,7 @@ jobs:
170170

171171
- name: Build container
172172
working-directory: ./docker
173-
run: docker build --build-arg jdk=${{ matrix.jdk }} -t $IMAGE_NAME -f ${{ matrix.tool.name }}/Dockerfile .
173+
run: docker build --build-arg jdk=${{ matrix.jdk }} ${{ matrix.tool.buildArgs[matrix.jdk] }} -t $IMAGE_NAME -f ${{ matrix.tool.name }}/Dockerfile .
174174

175175
- name: Compile in container
176176
run: docker run --entrypoint="" -v $(pwd)/lombok.jar:/workspace/lombok.jar $IMAGE_NAME /bin/bash -c "cd classpath; ${{ matrix.tool.cmd }}"
@@ -180,7 +180,7 @@ jobs:
180180
needs: build
181181
strategy:
182182
matrix:
183-
jdk: [8, 11, 17, 21, 23]
183+
jdk: [8, 11, 17, 21, 25]
184184
dir: [compileTests]
185185
fail-fast: false
186186

doc/changelog.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ Lombok Changelog
22
----------------
33

44
### v1.18.43 "Edgy Guinea Pig"
5-
* No changes since v1.18.42 yet.
5+
* BUGFIX: On JDK25, `val` and `@ExtensionMethod` could sometimes cause erroneous errors (in that you see errors but compilation succeeds anyway) using javac. [#3947](https://github.com/projectlombok/lombok/issues/3947).
6+
* BUGFIX: `@Jacksonized` + fields marked `transient` would result in those transient fields being serialised which is surprising (and thus undesired) behaviour. [#3936](https://github.com/projectlombok/lombok/issues/3936).
67

78
### v1.18.42 (September 18th, 2025)
89
* FEATURE: All the various `@Log` annotations now allow you to change their access level (they still default to `private`). [#2280](https://github.com/projectlombok/lombok/issues/2280). Thanks to new contributor Liam Pace!
File renamed without changes.

docker/maven/files/jdk-23/classpath/pom.xml renamed to docker/maven/files/jdk-25/classpath/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<java.version>23</java.version>
10+
<java.version>25</java.version>
1111
</properties>
1212

1313
<build>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<java.version>23</java.version>
10+
<java.version>25</java.version>
1111
</properties>
1212

1313
<build>

docker/provision/jdk/java-23.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

docker/provision/jdk/java-25.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
apt-get update && apt-get install -y wget
2+
wget https://github.com/adoptium/temurin25-binaries/releases/download/jdk-25%2B36/OpenJDK25U-jdk_x64_linux_hotspot_25_36.tar.gz -O jdk.tar.gz
3+
tar -xzf jdk.tar.gz -C /opt/
4+
mv /opt/jdk-25+36 /opt/jdk

src/core/lombok/core/configuration/ConfigurationFile.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ private static boolean fileExists(File file) {
9797
return file.exists() && file.isFile();
9898
}
9999

100-
private static String read(InputStream is) throws IOException {
100+
static String read(InputStream is) throws IOException {
101101
byte[] b = buffers.get();
102102
ByteArrayOutputStream out = new ByteArrayOutputStream();
103103
while (true) {
@@ -111,7 +111,7 @@ private static String read(InputStream is) throws IOException {
111111
private static class RegularConfigurationFile extends ConfigurationFile {
112112
private final File file;
113113
private ConfigurationFile parent;
114-
114+
115115
private RegularConfigurationFile(File file) {
116116
super(file.getPath());
117117
this.file = file;
@@ -172,7 +172,7 @@ CharSequence contents() throws IOException {
172172
is.close();
173173
}
174174
}
175-
175+
176176
@Override ConfigurationFile parent() {
177177
if (parent == null) {
178178
File parentFile = file.getParentFile().getParentFile();
@@ -322,15 +322,15 @@ private CharSequenceConfigurationFile(String identifier, CharSequence contents,
322322
@Override CharSequence contents() throws IOException {
323323
return contents;
324324
}
325-
325+
326326
@Override boolean exists() {
327327
return true;
328328
}
329-
329+
330330
@Override public ConfigurationFile resolve(String path) {
331331
return null;
332332
}
333-
333+
334334
@Override ConfigurationFile parent() {
335335
return null;
336336
}

src/core/lombok/eclipse/handlers/HandleJacksonized.java

Lines changed: 44 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2025 The Project Lombok Authors.
2+
* Copyright (C) 2020-2026 The Project Lombok Authors.
33
*
44
* Permission is hereby granted, free of charge, to any person obtaining a copy
55
* of this software and associated documentation files (the "Software"), to deal
@@ -43,6 +43,7 @@
4343
import lombok.ConfigurationKeys;
4444
import lombok.core.AnnotationValues;
4545
import lombok.core.HandlerPriority;
46+
import lombok.core.JacksonAnnotationType;
4647
import lombok.core.AST.Kind;
4748
import lombok.core.configuration.JacksonVersion;
4849
import lombok.core.handlers.HandlerUtil;
@@ -62,12 +63,9 @@
6263
@Provides
6364
@HandlerPriority(-512) // Above Handle(Super)Builder's level (builders must be already generated).
6465
public class HandleJacksonized extends EclipseAnnotationHandler<Jacksonized> {
65-
66-
private static final char[][] JACKSON3_JSON_POJO_BUILDER_ANNOTATION = Eclipse.fromQualifiedName("tools.jackson.databind.annotation.JsonPOJOBuilder");
67-
private static final char[][] JACKSON2_JSON_POJO_BUILDER_ANNOTATION = Eclipse.fromQualifiedName("com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder");
68-
private static final char[][] JACKSON3_JSON_DESERIALIZE_ANNOTATION = Eclipse.fromQualifiedName("tools.jackson.databind.annotation.JsonDeserialize");
69-
private static final char[][] JACKSON2_JSON_DESERIALIZE_ANNOTATION = Eclipse.fromQualifiedName("com.fasterxml.jackson.databind.annotation.JsonDeserialize");
70-
private static final char[][] JSON_PROPERTY_ANNOTATION = Eclipse.fromQualifiedName("com.fasterxml.jackson.annotation.JsonProperty");
66+
static boolean hasAnnotation(EclipseNode node, JacksonAnnotationType annotation) {
67+
return EclipseHandlerUtil.hasAnnotation(annotation.getQualifiedName(), node);
68+
}
7169

7270
@Override public void handle(AnnotationValues<Jacksonized> annotation, Annotation ast, EclipseNode annotationNode) {
7371
handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.JACKSONIZED_FLAG_USAGE, "@Jacksonized");
@@ -135,31 +133,30 @@ private void handleJacksonizedBuilder(Annotation ast, EclipseNode annotationNode
135133
}
136134

137135
// Insert @JsonDeserialize on annotated class.
138-
if (hasAnnotation("com.fasterxml.jackson.databind.annotation.JsonDeserialize", tdNode)) {
139-
annotationNode.addError("@JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.");
140-
return;
141-
}
142-
if (hasAnnotation("tools.jackson.databind.annotation.JsonDeserialize", tdNode)) {
136+
if (hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE2) || hasAnnotation(tdNode, JacksonAnnotationType.JSON_DESERIALIZE3)) {
143137
annotationNode.addError("@JsonDeserialize already exists on class. Either delete @JsonDeserialize, or remove @Jacksonized and manually configure Jackson.");
144138
return;
145139
}
146140
long p = (long) ast.sourceStart << 32 | ast.sourceEnd;
147141
TypeReference builderClassExpression = namePlusTypeParamsToTypeReference(builderClassNode, null, p);
148142
ClassLiteralAccess builderClassLiteralAccess = new ClassLiteralAccess(td.sourceEnd, builderClassExpression);
149143
MemberValuePair builderMvp = new MemberValuePair("builder".toCharArray(), td.sourceStart, td.sourceEnd, builderClassLiteralAccess);
150-
151-
JacksonVersion jacksonVersion = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, JacksonVersion.getDefault());
152-
if (jacksonVersion == null || !jacksonVersion.isValid()) {
153-
annotationNode.addError("No valid jackson version selected.");
154-
return;
144+
145+
List<JacksonVersion> jacksonVersions = annotationNode.getAst().readConfigurationOr(ConfigurationKeys.JACKSONIZED_JACKSON_VERSION, Arrays.<JacksonVersion>asList());
146+
147+
if (jacksonVersions.isEmpty()) {
148+
annotationNode.addWarning("Ambiguous: Jackson2 and Jackson3 exist; define which variant(s) you want in 'lombok.config'. See https://projectlombok.org/features/experimental/Jacksonized");
149+
jacksonVersions = Arrays.asList(JacksonVersion.TWO);
155150
}
156-
157-
if (jacksonVersion.useJackson2()) {
158-
td.annotations = addAnnotation(td, td.annotations, JACKSON2_JSON_DESERIALIZE_ANNOTATION, builderMvp);
151+
152+
if (jacksonVersions.contains(JacksonVersion.TWO)) {
153+
td.annotations = addAnnotation(td, td.annotations, JacksonAnnotationType.JSON_DESERIALIZE2.getQualifiednameAsCharArrayArray(), builderMvp);
159154
}
160-
if (jacksonVersion.useJackson3()) {
161-
td.annotations = addAnnotation(td, td.annotations, JACKSON3_JSON_DESERIALIZE_ANNOTATION, builderMvp);
155+
156+
if (jacksonVersions.contains(JacksonVersion.THREE)) {
157+
td.annotations = addAnnotation(td, td.annotations, JacksonAnnotationType.JSON_DESERIALIZE3.getQualifiednameAsCharArrayArray(), builderMvp);
162158
}
159+
163160
// Copy annotations from the class to the builder class.
164161
Annotation[] copyableAnnotations = findJacksonAnnotationsOnClass(td, tdNode);
165162
builderClass.annotations = copyAnnotations(builderClass, builderClass.annotations, copyableAnnotations);
@@ -169,15 +166,16 @@ private void handleJacksonizedBuilder(Annotation ast, EclipseNode annotationNode
169166
MemberValuePair withPrefixMvp = new MemberValuePair("withPrefix".toCharArray(), builderClass.sourceStart, builderClass.sourceEnd, withPrefixLiteral);
170167
StringLiteral buildMethodNameLiteral = new StringLiteral(buildMethodName.toCharArray(), builderClass.sourceStart, builderClass.sourceEnd, 0);
171168
MemberValuePair buildMethodNameMvp = new MemberValuePair("buildMethodName".toCharArray(), builderClass.sourceStart, builderClass.sourceEnd, buildMethodNameLiteral);
172-
if (jacksonVersion.useJackson2()) {
173-
builderClass.annotations = addAnnotation(builderClass, builderClass.annotations, JACKSON2_JSON_POJO_BUILDER_ANNOTATION, withPrefixMvp, buildMethodNameMvp);
169+
170+
if (jacksonVersions.contains(JacksonVersion.TWO)) {
171+
builderClass.annotations = addAnnotation(builderClass, builderClass.annotations, JacksonAnnotationType.JSON_POJO_BUILDER2.getQualifiednameAsCharArrayArray(), withPrefixMvp, buildMethodNameMvp);
174172
}
175-
if (jacksonVersion.useJackson3()) {
176-
builderClass.annotations = addAnnotation(builderClass, builderClass.annotations, JACKSON3_JSON_POJO_BUILDER_ANNOTATION, withPrefixMvp, buildMethodNameMvp);
173+
if (jacksonVersions.contains(JacksonVersion.THREE)) {
174+
builderClass.annotations = addAnnotation(builderClass, builderClass.annotations, JacksonAnnotationType.JSON_POJO_BUILDER3.getQualifiednameAsCharArrayArray(), withPrefixMvp, buildMethodNameMvp);
177175
}
176+
178177
// @SuperBuilder? Make it package-private!
179-
if (superBuilderAnnotationNode != null)
180-
builderClass.modifiers = builderClass.modifiers & ~ClassFileConstants.AccPrivate;
178+
if (superBuilderAnnotationNode != null) builderClass.modifiers = builderClass.modifiers & ~ClassFileConstants.AccPrivate;
181179
}
182180

183181
private void handleJacksonizedAccessors(Annotation ast, EclipseNode annotationNode, EclipseNode annotatedNode, EclipseNode tdNode, TypeDeclaration td, EclipseNode accessorsAnnotationNode, boolean jacksonizedBuilder) {
@@ -196,19 +194,33 @@ private void handleJacksonizedAccessors(Annotation ast, EclipseNode annotationNo
196194
// Add @JsonProperty to all fields. It will be automatically copied to the getter/setters later.
197195
for (EclipseNode eclipseNode : tdNode.down()) {
198196
if (eclipseNode.getKind() == Kind.FIELD) {
199-
createJsonPropertyForField(eclipseNode, annotationNode);
197+
if (hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_PROPERTY2) ||
198+
hasAnnotation(eclipseNode, JacksonAnnotationType.JSON_IGNORE2)) {
199+
return;
200+
} else if (eclipseNode.isTransient()) {
201+
createJsonIgnoreForField(eclipseNode, annotationNode);
202+
} else {
203+
createJsonPropertyForField(eclipseNode, annotationNode);
204+
}
200205
}
201206
}
202207
tdNode.rebuild();
203208
}
204209

205210
private void createJsonPropertyForField(EclipseNode fieldNode, EclipseNode annotationNode) {
206-
if (hasAnnotation("com.fasterxml.jackson.annotation.JsonProperty", fieldNode)) return;
207211
ASTNode astNode = fieldNode.get();
208212
if (astNode instanceof FieldDeclaration) {
209-
FieldDeclaration fd = (FieldDeclaration)astNode;
213+
FieldDeclaration fd = (FieldDeclaration) astNode;
210214
StringLiteral fieldName = new StringLiteral(fd.name, 0, 0, 0);
211-
((FieldDeclaration) astNode).annotations = addAnnotation(fieldNode.get(), fd.annotations, JSON_PROPERTY_ANNOTATION, fieldName);
215+
((FieldDeclaration) astNode).annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_PROPERTY2.getQualifiednameAsCharArrayArray(), fieldName);
216+
}
217+
}
218+
219+
private void createJsonIgnoreForField(EclipseNode fieldNode, EclipseNode annotationNode) {
220+
ASTNode astNode = fieldNode.get();
221+
if (astNode instanceof FieldDeclaration) {
222+
FieldDeclaration fd = (FieldDeclaration) astNode;
223+
((FieldDeclaration) astNode).annotations = addAnnotation(fieldNode.get(), fd.annotations, JacksonAnnotationType.JSON_IGNORE2.getQualifiednameAsCharArrayArray());
212224
}
213225
}
214226

0 commit comments

Comments
 (0)