Integrated: 8365314: javac fails with an exception for erroneous source
Jan Lahoda
jlahoda at openjdk.org
Thu Aug 14 07:08:17 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`.
This pull request has now been integrated.
Changeset: a6be2286
Author: Jan Lahoda <jlahoda at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/a6be2286421e069a292c749eecd6bdc38a8deaf2
Stats: 34 lines in 2 files changed: 25 ins; 0 del; 9 mod
8365314: javac fails with an exception for erroneous source
Reviewed-by: vromero
-------------
PR: https://git.openjdk.org/jdk/pull/26758
More information about the compiler-dev
mailing list