[ https://issues.apache.org/jira/browse/MCOMPILER-546?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767516#comment-17767516 ]
Vlad Galuska commented on MCOMPILER-546: ---------------------------------------- [~michael-o] Replaced with text > 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 > Priority: Major > Attachments: 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 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] > -- This message was sent by Atlassian Jira (v8.20.10#820010)