RFR: 8361401: Warnings for use of Sun APIs should not be mandatory
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Jul 4 15:23:53 UTC 2025
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.
-------------
Commit messages:
- Remove Log::strictWarning
- Merge with latest compiler changes
- Initial push
Changes: https://git.openjdk.org/jdk/pull/26129/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=26129&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8361401
Stats: 69 lines in 6 files changed: 38 ins; 16 del; 15 mod
Patch: https://git.openjdk.org/jdk/pull/26129.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/26129/head:pull/26129
PR: https://git.openjdk.org/jdk/pull/26129
More information about the compiler-dev
mailing list