RFR: 8371309: Diagnostic.getEndPosition can throw an NPE with typical broken code [v2]

Liam Miller-Cushon cushon at openjdk.org
Wed Nov 26 13:58:58 UTC 2025


On Wed, 26 Nov 2025 13:42:10 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> Note that this was not intended to change the end pos for synthetic trees, just for diagnostics based on synthetic trees. I see there are a few calls to `JCTree.getEndPosition` in javac (some a bit misguided), but none that would immediately obviously change the outcome for synthetic trees.

Ah, OK, thanks. I filed https://bugs.openjdk.org/browse/JDK-8372611 with a repro.

I don't really have concerns about either behaviour here, but it's helpful to have some way to identify synthetic AST nodes, and this broke some clients of the internal javac APIs that were checking for `endpos == NOPOS` to detect synthetic AST nodes.

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

PR Comment: https://git.openjdk.org/jdk/pull/28316#issuecomment-3581440002


More information about the compiler-dev mailing list