Integrated: 8361401: Warnings for use of Sun APIs should not be mandatory

Maurizio Cimadamore mcimadamore at openjdk.org
Wed Jul 16 09:57:45 UTC 2025


On Fri, 4 Jul 2025 10:57:39 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> During Java 8, we changed the code that reported use of Sun API warnings (e.g. `com.sun.misc.Unsafe`) to use `Log::mandatoryWarning` instead of `Log::strictWarning`. This change had two effects:
> 
> * warnings for use of Sun API would *not* be emitted if more than 100 warnings were displayed
> * warnings for use of Sun API would become [mandatory warnings](https://download.java.net/java/early_access/jdk25/docs/api/java.compiler/javax/tools/Diagnostic.Kind.html#MANDATORY_WARNING)
> 
> The latter is particularly bad, because the definition of a mandatory warning is that of a warning mandated by the specification. Currently we only use the mandatory status for unchecked, deprecation and preview warnings.
> 
> This PR reverts the behavior to what it was before Java 8. That is, the warning for Sun API use is now marked with the `STRICT` flag -- and `Log` will not attempt to filter out warnings with such flag. As a result, the (unused) method `Log::strictWarning` can be removed.
> 
> I've tweaked an existing test to check the kind of the Sun API warnings.

This pull request has now been integrated.

Changeset: b787ad6f
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/b787ad6f690df5c82a1efc5ccac658a9238ff201
Stats:     69 lines in 6 files changed: 38 ins; 16 del; 15 mod

8361401: Warnings for use of Sun APIs should not be mandatory

Reviewed-by: jlahoda, vromero

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

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


More information about the compiler-dev mailing list