RFR: 8297988: NPE in JavacTypes.getOverriddenMethods from doclint

Jan Lahoda jlahoda at openjdk.org
Tue Dec 6 12:28:46 UTC 2022

There are a few cases where `javac` parses Java source code, reads some name from the AST, and throws it away. This is used e.g. when validating `exports` directive in the `module-info`, if there are no classfiles and no source files used in the current compilation from the given package, `javac` will peek into the sources in the package, looking at their package clause[1]. The ASTs produced by such parses are thrown away/not part of the upcoming compilation.

But, even parses like this are reported to the `TaskListener`s, and some of the listeners may expect that the AST is eventually attributed - but it is not, as it was used only to read some name from the source code. Specifically, for DocLint, this may lead to an NPE, but it may cause other issues as well.

The proposal here is to simply avoid sending the "parse" event for parses that are not part of the actual compilation.

[1] https://github.com/openjdk/jdk/blob/84b927a05bcb7bf32a12829070ffd3a5670066d2/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java#L1040


Commit messages:
 - 8297988: NPE in JavacTypes.getOverriddenMethods from doclint

Changes: https://git.openjdk.org/jdk/pull/11535/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=11535&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8297988
  Stats: 115 lines in 2 files changed: 111 ins; 0 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/11535.diff
  Fetch: git fetch https://git.openjdk.org/jdk pull/11535/head:pull/11535

PR: https://git.openjdk.org/jdk/pull/11535

More information about the compiler-dev mailing list