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

javac crashes on unresolvable constant in @SuppressWarnings

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • 26
    • 25, 26
    • tools
    • None

      Consider this code:
      ```
      @SuppressWarnings(CONST)
      public class Ann {
          public static final String CONST = "";
      }
      ```

      javac crashes on it:
      ```
      $ javac -XDdev /tmp/Ann.java
      /tmp/Ann.java:1: error: cannot find symbol
      @SuppressWarnings(CONST)
                        ^
        symbol: variable CONST
      1 error
      An exception has occurred in the compiler (26-internal). Please file a bug against the Java compiler via the Java bug reporting page (https://bugreport.java.com) after checking the Bug Database (https://bugs.java.com) for duplicates. Include your program, the following diagnostic, and the parameters passed to the Java compiler in your report. Thank you.
      java.lang.ClassCastException: class com.sun.tools.javac.code.Attribute$Error cannot be cast to class com.sun.tools.javac.code.Attribute$Constant (com.sun.tools.javac.code.Attribute$Error and com.sun.tools.javac.code.Attribute$Constant are in module jdk.compiler of loader 'app')
              at jdk.compiler/com.sun.tools.javac.code.Lint.suppressionsFrom(Lint.java:533)
              at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:214)
              at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:197)
              at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
              at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
              at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
              at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
              at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:153)
              at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:176)
              at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
              at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:632)
              at jdk.compiler/com.sun.tools.javac.code.Lint.suppressionsFrom(Lint.java:524)
              at jdk.compiler/com.sun.tools.javac.code.Lint.suppressionsFrom(Lint.java:511)
              at jdk.compiler/com.sun.tools.javac.code.Lint.augment(Lint.java:82)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5414)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attribClass(Attr.java:5365)
              at jdk.compiler/com.sun.tools.javac.comp.Attr.attrib(Attr.java:5302)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.attribute(JavaCompiler.java:1346)
              at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:968)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:319)
              at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:178)
              at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:66)
              at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:52)
      printing javac parameters to: /tmp/javac.20250706_093450.args
      ```

            jlahoda Jan Lahoda
            jlahoda Jan Lahoda
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: