RFR: 8350212: Track source end positions of declarations that support @SuppressWarnings [v7]

Maurizio Cimadamore mcimadamore at openjdk.org
Fri May 30 21:55:03 UTC 2025


On Fri, 30 May 2025 20:11:12 GMT, Archie Cobbs <acobbs at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Lower.java line 2063:
>> 
>>> 2061:             make_at(tree.pos());
>>> 2062:             T result = super.translate(tree);
>>> 2063:             if (endPosTable != null && result != null && result != tree) {
>> 
>> I wonder how this extra check for `result != null` was added. I mean, of course calling `replaceTree` with a null parameter seems suspicious -- should we add more formal null checks in the various end pos table methods? (it's ok if we do that in a separate PR)
>
> I added this check to fix NPE's (e.g., in `tools/javac/warnings/suppress/PackageInfo.java`) that started to occur after the refactoring of `EndPosTable.replaceTree()`, which assumes that the replacement is not null.
> 
> Of couse a null node can't have an ending position, but it does happen sometimes that nodes are replaced with nulls. In that case, it makes sense for `replaceTree()` to just remove the old tree from `EndPosTable`. I've updated the patch accordingly in 205f77e9d53.

I see -- so this started to happen now because before we used to just do nothing if the empty end pos table was set. Makes sense.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/23669#discussion_r2116709721


More information about the compiler-dev mailing list