A DESCRIPTION OF THE PROBLEM :
When using javac "enable-preview" along with "debug" flag, the output class seems borked.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac --enable-preview --release 21 -g org/example/Main.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
$ java --enable-preview org.example.Main
Hello, World!
Hello, World!
Hello, World!
ACTUAL -
$ java --enable-preview org.example.Main
Error: LinkageError occurred while loading main class org.example.Main
java.lang.ClassFormatError: Illegal field name "" in class org/example/Main
---------- BEGIN SOURCE ----------
package org.example;
import java.util.List;
public class Main {
public static void main(String[] args) {
for (var _ : List.of(1, 2, 3)) {
System.out.println("Hello, World!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not specify --enable-prefix and -g together. Note: maven compiler plugin BY DEFAULT sets javac -g flag (debug).
FREQUENCY : always
When using javac "enable-preview" along with "debug" flag, the output class seems borked.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
javac --enable-preview --release 21 -g org/example/Main.java
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
$ java --enable-preview org.example.Main
Hello, World!
Hello, World!
Hello, World!
ACTUAL -
$ java --enable-preview org.example.Main
Error: LinkageError occurred while loading main class org.example.Main
java.lang.ClassFormatError: Illegal field name "" in class org/example/Main
---------- BEGIN SOURCE ----------
package org.example;
import java.util.List;
public class Main {
public static void main(String[] args) {
for (var _ : List.of(1, 2, 3)) {
System.out.println("Hello, World!");
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not specify --enable-prefix and -g together. Note: maven compiler plugin BY DEFAULT sets javac -g flag (debug).
FREQUENCY : always
- duplicates
-
JDK-8313323 javac -g on a java file which uses unnamed variable leads to ClassFormatError when launching that class
- Resolved
-
JDK-8317378 Using _ in try with resources results in ClassFormatError
- Closed