-
Notifications
You must be signed in to change notification settings - Fork 182
Description
Affected version
latest (docker image 3.9.11-eclipse-temurin-25)
Bug description
I have the following classes in a non standard tree (the files are directly in src, instead of src/main/java).
package com.test;
public enum State {
FINISHED,
PENDING
}package com.test;
import javax.swing.SwingWorker;
public class Test extends SwingWorker<Void, Void> {
@Override
public Void doInBackground() throws Exception {
Object state2 = State.FINISHED;
return null;
}
}And the following pom.xml
<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.test</groupId>
<artifactId>compile-bug</artifactId>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.install.skip>true</maven.install.skip>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
</project>When I compile this project using latest Docker maven image (currently 3.9.11-eclipse-temurin-25), I get the following error message:
docker run --rm -v $(pwd):/app -v ~/.m2:/root/.m2 -w /app maven:latest mvn clean compile[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /app/src/com/test/Test.java:[9,38] cannot find symbol
symbol: variable FINISHED
location: class java.util.concurrent.Future.State
[INFO] 1 error
The compiler is misleading between the Future.State imported in the superclass of Test and the State class available in the same package than Test.
I also check maven:3-eclipse-temurin-21 with the same failure.
If I do one of the following, the problem disappears:
- Use an quite old release of maven (maven:3-jdk-8)
- Put the source files in default source directory and remove the pom's build section.
- Add a
import static com.test.State.*;inTest.javaand replaceState.FINISHEDbyFINISHED.
The following project contains a ready to use Maven project to reproduce the bug.
Thanks for reading!
PS: JDK 8 does not have a Future.State class (introduced in Java 19). This could explain why the compilation is working.