On Fri, 1 Oct 2021 15:41:17 GMT, Jonathan Gibbons <[email protected]> wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/tree/DCTree.java line 225: >> >>> 223: } >>> 224: >>> 225: return Position.NOPOS; >> >> This method should return Diagnostic.NOPOS. >> >> I'm concerned with mixing com.sun.tools.javac.util.Position.NOPOS and >> javax.tools.Diagnostic.NOPOS. Although they currently have the same int >> value, they are of different types, used in different contexts, and not >> guaranteed to remain equal in the future. We might need to do something >> about it. > > 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. ------------- PR: https://git.openjdk.java.net/jdk/pull/5510
