RFR: 8365314: javac fails with an exception for erroneous source

Jan Lahoda jlahoda at openjdk.org
Wed Aug 13 12:35:23 UTC 2025


For very broken code like:

$ cat /tmp/BrokenSuppressWarnings.java
@SuppressWarnings
public class BrokenSuppressWarnings {}


javac may fail with an exception:

$ javac -XDdev /tmp/BrokenSuppressWarnings.java
/tmp/BrokenSuppressWarnings.java:1: error: annotation @SuppressWarnings is missing a default value for the element 'value'
@SuppressWarnings
^
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.NullPointerException: Cannot read field "values" because "values" is null
        at jdk.compiler/com.sun.tools.javac.code.Lint.suppressionsFrom(Lint.java:532)
...
printing javac parameters to: /tmp/javac.20250812_114830.args


This is because the `Attribute` for `value` is missing. The proposed solution here is to ignore the missing attribute/`null`, by using `instanceof`.

-------------

Commit messages:
 - 8365314: javac fails with an exception for erroneous source

Changes: https://git.openjdk.org/jdk/pull/26758/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26758&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8365314
  Stats: 34 lines in 2 files changed: 25 ins; 0 del; 9 mod
  Patch: https://git.openjdk.org/jdk/pull/26758.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26758/head:pull/26758

PR: https://git.openjdk.org/jdk/pull/26758


More information about the compiler-dev mailing list