RFR: 8260053: Optimize Tokens' use of Names

Jonathan Gibbons jjg at openjdk.java.net
Wed Jan 20 18:25:54 UTC 2021


On Wed, 20 Jan 2021 17:07:26 GMT, Guoxiong Li <github.com+13688759+lgxbslgx at openjdk.org> wrote:

> Hi all,
> 
> This patch initializes the names about `TokenKind` at the beginning of the constructor of the class `Names`. As a result, the `Tokens.maxKey` and the length of the array `Tokens.key` become small. By using this patch, the length of the array `Tokens.key` is changed from 4280 to 383.
> 
> The original discussion is at [compiler-dev](https://mail.openjdk.java.net/pipermail/compiler-dev/2021-January/016126.html).
> 
> Thank you for taking the time to review.
> 
> Best Regards.

src/jdk.compiler/share/classes/com/sun/tools/javac/util/Names.java line 29:

> 27: 
> 28: import com.sun.tools.javac.parser.Tokens.TokenKind;
> 29: 

I realize why you need this, but this is a questionable import from an architectural point of view.   Spaghetti imports can be a problem, and the intent has been that `utils` is a collection of low-level utility classes, and the parser is a layer built on top of that:  here, you are adding a reverse dependence, so that a class in `utils` depends on a class in `parser`.

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

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


More information about the compiler-dev mailing list