RFR: JDK-8273244: Improve diagnostic output related to ErroneousTree [v3]

Jonathan Gibbons jjg at openjdk.java.net
Wed Sep 29 03:13:41 UTC 2021


On Mon, 27 Sep 2021 18:00:07 GMT, Pavel Rappo <prappo at openjdk.org> wrote:

> > Apart from fixing generally bad behavior, there is one other tiny behavioral change. For an empty DocCommentTree the ending position is now the same at the starting position, and not NOPOS.
> 
> I suppose we don't need to reflect this change anywhere in the API (CSR), do we?

I don't believe the specification is so fine-grained.

> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java line 174:
> 
>> 172:             case IDENTIFIER -> {
>> 173:                 DCIdentifier ident = (DCIdentifier) this;
>> 174:                 return ident.pos + ident.name.length();
> 
> While in JavacTrees, this logic contained some special handling for `names.error`. What was that about?

`names.error` is used by javac in various error conditions. It has the string  value `<error>`.  I don't believe it can arise in `DocTree` nodes, so I dropped the code.

> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java line 192:
> 
>> 190:             case ENTITY -> {
>> 191:                 DCEntity endEl = (DCEntity) this;
>> 192:                 return endEl.pos + endEl.name.length() + 2;
> 
> A similar question about `names.error`.

Similar answer.

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

PR: https://git.openjdk.java.net/jdk/pull/5510


More information about the compiler-dev mailing list