RFR: JDK-8273244: Improve diagnostic output related to ErroneousTree [v5]
Pavel Rappo
prappo at openjdk.java.net
Mon Oct 4 13:55:13 UTC 2021
On Fri, 1 Oct 2021 16:23:24 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:
>> Hmmm. I doubt this is the only place where the values are conflated. I'll check with other `javac` folk about defining `com.sun.tools.javac.util.Position.NOPOS` in terms of `javax.tools.Diagnostic.NOPOS`. The internal version predates the public value, but the two are intended to be the same.
>
> I changed the line, but only to remove the redundant use of `Position.`
> The two values, `Diagnostic.NOPOS` and `Position.NOPOS` are intended to be the same value, allowing for the difference in type. The difference in type for `NOPOS`, and all methods in `Trees` (and `DocTrees`) that return positions, was intended to allow other implementations of `javax.tools` to handle longer source files (!!!) even though `javac` only support `int`-sized files.
Would you consider changing the definition of `Position.NOPOS` to this as you described elsewhere?
Position.NOPOS = (int) Diagnostic.NOPOS
Separately, consider adding these two assertions to com.sun.tools.javac.util.Position:
static {
assert NOPOS == ((int) javax.tools.Diagnostic.NOPOS);
assert ((long) NOPOS) == javax.tools.Diagnostic.NOPOS;
}
These assertions would document our intent clearly and verifiably: these constants can be used interchangeably, barring occasional downcasting.
-------------
PR: https://git.openjdk.java.net/jdk/pull/5510
More information about the compiler-dev
mailing list