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

Vicente Romero vromero at openjdk.org
Wed Aug 13 15:39:10 UTC 2025


On Wed, 13 Aug 2025 12:28:16 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> 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`.

lgtm

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

Marked as reviewed by vromero (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26758#pullrequestreview-3116581273


More information about the compiler-dev mailing list