RFR: 8263926: JavacFileManager.hasExplicitLocation fails with NPE while compiling [v2]

Guoxiong Li gli at openjdk.java.net
Fri Jun 18 16:29:38 UTC 2021

On Fri, 18 Jun 2021 16:22:26 GMT, Guoxiong Li <gli at openjdk.org> wrote:

>> src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Modules.java line 539:
>>> 537:         try {
>>> 538:             JavaFileObject fo = tree.sourcefile;
>>> 539:             if (msym.sourceLocation != null && fileManager.contains(msym.sourceLocation, fo)) {
>> What is the module for which the `sourceLocation` is `null` ... in other words, it is reasonable for this method to be called with a module with no source location, or is this check just hiding some other bug elsewhere?
> @jonathan-gibbons Thanks for the comment. Your worry is right. I do more investigation in the source code today.
> The logic of the method `ClassFinder#scanUserPaths` seems wrong. 
> When the `fileManager.hasLocation(SOURCE_PATH)` (means `haveSourcePath` in my updated code) is true and the `includeSourcePath` is false, the compiler shouldn't search any source path and source files.
> I seperated the situations and revised the code and test. What do you think about the updated code?
> I worry that this change may cause some regressions. Currently, the `tools/javac` passed locally.
> I am still waiting for the `Pre-submit tests` to finish.

And about the null check, I want to keep it so that the compiler won't crash when meeting the situation like this bug.


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

More information about the compiler-dev mailing list