Skip to content

Commit 3ba6e5a

Browse files
timtebeekTim te Beekclaude
authored
Add integration test for JDK 25 LinkageError with Lombok (#1109)
Verifies that the rewrite plugin can parse JDK 25 projects using Lombok on comment-free main sources with commented test sources, which previously triggered a LinkageError in JavaUnrestrictedClassLoader.defineClass(). Co-authored-by: Tim te Beek <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]>
1 parent b5138fc commit 3ba6e5a

5 files changed

Lines changed: 105 additions & 0 deletions

File tree

src/test/java/org/openrewrite/maven/RewriteRunIT.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import com.soebes.itf.jupiter.maven.MavenExecutionResult;
2020
import org.junit.jupiter.api.Disabled;
2121
import org.junit.jupiter.api.condition.DisabledOnOs;
22+
import org.junit.jupiter.api.condition.EnabledForJreRange;
23+
import org.junit.jupiter.api.condition.JRE;
2224
import org.junit.jupiter.api.condition.OS;
2325
import org.openrewrite.maven.jupiter.extension.GitJupiterExtension;
2426

@@ -243,4 +245,16 @@ void plaintext_masks(MavenExecutionResult result) {
243245
)
244246
.doesNotContain("in-root.ignored");
245247
}
248+
249+
/**
250+
* On JDK 25, Lombok annotation processing on comment-free main sources followed by test sources
251+
* with comments triggers a LinkageError in JavaUnrestrictedClassLoader.defineClass().
252+
* Requires --add-exports flags in .mvn/jvm.config for the fallback to work.
253+
*/
254+
@MavenTest
255+
@EnabledForJreRange(min = JRE.JAVA_25)
256+
void lombok_jdk25_linkage_error(MavenExecutionResult result) {
257+
assertThat(result)
258+
.isSuccessful();
259+
}
246260
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
2+
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
3+
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
4+
--add-exports jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED
5+
--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
6+
--add-exports jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
7+
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
8+
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.openrewrite.maven</groupId>
7+
<artifactId>lombok_jdk25_linkage_error</artifactId>
8+
<version>1.0</version>
9+
<packaging>jar</packaging>
10+
<name>RewriteRunIT#lombok_jdk25_linkage_error</name>
11+
12+
<properties>
13+
<maven.compiler.source>25</maven.compiler.source>
14+
<maven.compiler.target>25</maven.compiler.target>
15+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16+
</properties>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.projectlombok</groupId>
21+
<artifactId>lombok</artifactId>
22+
<version>1.18.38</version>
23+
<scope>provided</scope>
24+
</dependency>
25+
</dependencies>
26+
27+
<build>
28+
<plugins>
29+
<plugin>
30+
<groupId>org.apache.maven.plugins</groupId>
31+
<artifactId>maven-compiler-plugin</artifactId>
32+
<version>3.14.0</version>
33+
<configuration>
34+
<forceJavacCompilerUse>true</forceJavacCompilerUse>
35+
<annotationProcessorPaths>
36+
<path>
37+
<groupId>org.projectlombok</groupId>
38+
<artifactId>lombok</artifactId>
39+
<version>1.18.38</version>
40+
</path>
41+
</annotationProcessorPaths>
42+
</configuration>
43+
</plugin>
44+
<plugin>
45+
<groupId>@project.groupId@</groupId>
46+
<artifactId>@project.artifactId@</artifactId>
47+
<version>@project.version@</version>
48+
<configuration>
49+
<activeRecipes>
50+
<recipe>org.openrewrite.java.format.AutoFormat</recipe>
51+
</activeRecipes>
52+
</configuration>
53+
</plugin>
54+
</plugins>
55+
</build>
56+
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package sample;
2+
3+
import lombok.Data;
4+
import lombok.Builder;
5+
import lombok.With;
6+
7+
@Data
8+
@Builder
9+
public class App {
10+
@With
11+
private String name;
12+
private int count;
13+
private boolean active;
14+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package sample;
2+
3+
public class AppTest {
4+
void testApp() {
5+
// GIVEN
6+
var name = "test";
7+
var count = 1;
8+
// WHEN
9+
var app = App.builder().name(name).count(count).active(true).build();
10+
// THEN
11+
assert app.getName().equals(name);
12+
}
13+
}

0 commit comments

Comments
 (0)