RFR: 8372948: Store end positions directly in JCTree [v6]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jan 26 16:15:00 UTC 2026


On Mon, 26 Jan 2026 12:09:47 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java line 675:
>> 
>>> 673:             case PREINC:
>>> 674:             case PREDEC:
>>> 675:                 return getEndPos(((JCOperatorExpression) tree).getOperand(RIGHT));
>> 
>> Is this big switch still needed? When would an end position not be set in this new world?
>
> `JavacParser` is still only recording end positions for the trees where it calls `storeEnd`, so the same kinds of trees have end positions recorded in the new world. I think that potentially `JavacParser` could start recording end positions for all trees, and then this switch could be removed. I will investigate that more. If it works out, I wonder if it might be better as a separate follow-up change, to keep the initial refactoring to remove the end pos table as behaviour preserving as possible. What do you think?

I think it's ok to start simple and refine as we go. As part of this change it would be perhaps helpful to at least simplify the method so that "unreachable cases" are removed?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28610#discussion_r2728246474


More information about the compiler-dev mailing list