RFR: 8286573: Remove the unnecessary method Attr#attribTopLevel and its usage

Guoxiong Li gli at openjdk.java.net
Wed May 11 08:57:20 UTC 2022


Hi all,

The original patch [1] added the method `Attr#attribTopLevel` to validate the annotations of the package. Then the annotation validation was moved to the annotation pipeline [2] and the TopLevel tree node was refactored (added JCPackageDecl) [3]. So now the `Attr#attribTopLevel` is replaced by method `attribPackage` and actually is not used by any code. It is good to remove it.

And there are only 3 places (shown below) that add the `Env` instance to the `Todo` list which the `Attr` uses as input. They add the `Env` of module, package, class seperately to the todo list . So the `Attr` doesn't need to handle the situation about TopLevel JCCompilationUnit.

1. Enter::visitTopLevel  `todo.append(packageEnv)`
2. Enter::visitModuleDef `todo.append(moduleEnv)`
3. ImportsPhase::runPhase `todo.append(env)`

Thanks for taking the time to review.

Best Regards,
-- Guoxiong

[1]https://github.com/openjdk/jdk/commit/13d31713dc6ac7134d81abeb11a659df2104d71f
[2]https://github.com/openjdk/jdk/commit/da21af58f4811285f7050691d51fe32600c0e5f8
[3]https://github.com/openjdk/jdk/commit/9783b65028eba41796c3e05ebb545b1a722f56b0

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

Commit messages:
 - JDK-8286573

Changes: https://git.openjdk.java.net/jdk/pull/8648/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=8648&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8286573
  Stats: 16 lines in 1 file changed: 0 ins; 16 del; 0 mod
  Patch: https://git.openjdk.java.net/jdk/pull/8648.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/8648/head:pull/8648

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


More information about the compiler-dev mailing list