Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8317002

Combination of javac flags produce broken bytecode in compiler output

    XMLWordPrintable

Details

    • generic
    • generic

    Description

      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


      Attachments

        Issue Links

          Activity

            People

              adev ANUPAM DEV
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: