RFR: Downgrade subtyping/cast failures from errors to warnings
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Jan 8 19:17:25 UTC 2026
On Thu, 8 Jan 2026 19:11:03 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:
> This PR reverts all changes to subtyping and cast conversion, meaning that assigning `null` to a null-restricted type is no longer an error.
> I've resurrected the lint `null` category, to issue a warning in such cases.
>
> There's some stuff left to do, as I realized that the compiler swallows null markers when emitting diagnostics. This is due to a conundrum in the diagnostic formatter calling `stripMetadata`, and that resulting in _all_ metadata (not just type annos) to be lost.
src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties line 4390:
> 4388: compiler.warn.suspicious.nullness.conversion=\
> 4389: Suspicious nullness conversion\n\
> 4390: required: {0}!\n\
Note the `!` here -- it's an hack, since the compiler swallows it :-(
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1872#discussion_r2673551219
More information about the valhalla-dev
mailing list