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

Guoxiong Li gli at openjdk.java.net
Fri Jun 18 16:25:30 UTC 2021


On Thu, 17 Jun 2021 18:47:12 GMT, Jonathan Gibbons <jjg at openjdk.org> wrote:

>> Guoxiong Li has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Adjust the comments
>
> 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.

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

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


More information about the compiler-dev mailing list