Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Information Provided
-
3.11.0
-
None
-
None
-
Both MacOS and Windows.
Maven 3.9.4
Maven Compiler 3.11
Java 21 Preview
Description
I'm trying to test out the preview feature described in JEP 443: Unnamed patterns and variables https://openjdk.org/jeps/443 . I have the following:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>21</source> <target>21</target> <compilerArgs> <arg>--enable-preview</arg> </compilerArgs> </configuration> </plugin>
I then run `mvn -X compile`, the result of which has been attached as mvn-compile.log.
The target just contains the Main.class file and the `createdFiles.lst` with: `org/example/Main.class` and `inputFiles.lst` with: `/Users/vlad.galuska/IdeaProjects/preview/Java21Preview/src/main/java/org/example/Main.java`
Note: The picture is from IntelIJ but all the commands have been run from the command line.
When running the generated .class file:
`cd target/classes `
`java --enable-preview org.example.Main`
I get the following message:
```
Error: LinkageError occurred while loading main class org.example.Main
java.lang.ClassFormatError: Illegal field name "" in class org/example/Main
```
This only happens when using the maven compiler plugin as when compiling manually from the command line:
`javac --enable-preview --release 21 org/example/Main.java `
`java --enable-preview org.example.Main `
I get the intended result:
```
Hello, World!
Hello, World!
Hello, World!
```
The same behavior has been recorded on Windows. I've also tried this with the amazon coretto version of java 21, OpenJDK Java 21 GA release and OpenJDK java 21.ea.35-open.
Maven is also a clean install of 3.9.4, but was reproduced with a 3.8 I had installed previously.
Here's also a repository where I have uploaded the code base for this bug report:
https://github.com/VladGaluska/jdk21-preview-bug
Attachments
Attachments
Issue Links
- relates to
-
SUREFIRE-2200 JEP 443: Illegal field name "" in class
- Closed
-
SUREFIRE-2201 JDK21: Crash when using new '_' wildcard preview feature in test classes
- Closed
- links to