[BUG] Wildcard import and var usage cause compilation failure in JDK27
Describe the bug Using JDK 27 (both amazon corretto and oracle openJDK were tested under MacOs ARM64) Importing lombok using 'import lombok.*' and using a var statement cause the maven compiler to fail with an assertion error: java.lang.AssertionError at jdk.compiler/com.sun.tools.javac.comp.Attr.visitTree(Attr.java:5310) at jdk.compiler/com.sun.tools.javac.tree.JCTree$Visitor.visitVarType(JCTree.java:3626) at jdk.compiler/com.sun.tools.javac.tree.JCTree$JCVarType.accept(JCTree.java:2834) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribTree(Attr.java:679) at jdk.compiler/com.sun.tools.javac.comp.Attr.attribType(Attr.java:749)
To Reproduce Java source file (the unused wildcard import is necessary as well as the var keyword):
package com.example.repro;
import lombok.*;
public class Entity1 {
public static Entity1 create() {
var entity = new Entity1();
return entity;
}
}projects pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>jdk27-lombok-repro</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<maven.compiler.release>27</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<lombok.version>1.18.48</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.16.0</version>
<configuration>
<release>27</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
</project>running this using mvn compile results in compilation error
Expected behavior No compilation error
Version info (please complete the following information):
- 1.18.48
- Platform: MacOS, using Javac27 and maven: Apache Maven 3.9.11 (3e54c93a704957b63ee3494413a2b544fd3d825b) Maven home: /Applications/IntelliJ IDEA.app/Contents/plugins/maven/lib/maven3 Java version: 27, vendor: Amazon.com Inc., runtime: /Users/xxx/Library/Java/JavaVirtualMachines/corretto-27/Contents/Home Default locale: de_DE, platform encoding: UTF-8 OS name: "mac os x", version: "27.0", arch: "aarch64", family: "mac"
Additional context I am not entirely sure if this is caused by lombok or the new JDK of course, but I was also able to reproduce this using the oracle open Jdk 27. Maybe I am doing something wrong here too, the bug happened initally in a much larger project while migrating to JDK 27. I removed all the wildcard imports and replaced them with specific ones and it worked. But I would like this to work with wildcard imports too.
If there is anything I can do to help clarifying the situation, hit me up.
Source: projectlombok/lombok