Vlad Galuska created MCOMPILER-546: -------------------------------------- Summary: Maven compiling fails when using JEP 443 Key: MCOMPILER-546 URL: https://issues.apache.org/jira/browse/MCOMPILER-546 Project: Maven Compiler Plugin Issue Type: Bug Affects Versions: 3.11.0 Environment: Both MacOS and Windows. Maven 3.9.4 Maven Compiler 3.11 Java 21 Preview Reporter: Vlad Galuska Attachments: image-2023-09-21-14-15-13-708.png, image-2023-09-21-14-20-35-050.png, mvn-compile-1.log, pom.xml
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: {code:java} <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> {code} I then run `mvn -X compile`, the result of which has been attached as mvn-compile.log. The target has the following structure (all good here): !image-2023-09-21-14-15-13-708.png|width=376,height=330! {*}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: !image-2023-09-21-14-20-35-050.png|width=677,height=54! 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 -- This message was sent by Atlassian Jira (v8.20.10#820010)