[jdk20] Integrated: 8297988: NPE in JavacTypes.getOverriddenMethods from doclint

Jan Lahoda jlahoda at openjdk.org
Fri Dec 9 11:14:18 UTC 2022


On Thu, 8 Dec 2022 18:12:20 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:

> [This PR was originally submitted as https://github.com/openjdk/jdk/pull/11535 to the mainline JDK.]
> 
> 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

This pull request has now been integrated.

Changeset: 133ad8e1
Author:    Jan Lahoda <jlahoda at openjdk.org>
URL:       https://git.openjdk.org/jdk20/commit/133ad8e1734f002f013dd3c73d496e323e9e881e
Stats:     115 lines in 2 files changed: 111 ins; 0 del; 4 mod

8297988: NPE in JavacTypes.getOverriddenMethods from doclint

Reviewed-by: vromero, jjg

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

PR: https://git.openjdk.org/jdk20/pull/2


More information about the compiler-dev mailing list