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

Jan Lahoda jlahoda at openjdk.org
Fri Jul 4 15:28:41 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.

Looks good to me.

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

Marked as reviewed by jlahoda (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/26129#pullrequestreview-2987683863


More information about the compiler-dev mailing list