RFR: JDK-8217868: Crash for overlap between source path and patch module path

Jan Lahoda jan.lahoda at oracle.com
Thu Feb 7 16:42:15 UTC 2019


Hi,

Consider code like this:
---src/module-info.java
module m { uses test.Test; }
---src/test/Test.java
package test; public class Test { }

And javac invocation like:
javac -sourcepath src --patch-module m2=src module-info.java

While analysing the module-info, javac will try to lazily/implicitly 
load the test.Test class. And when Modules.setCompilationUnitModules is 
called for test.Test, it will eventually call singleModuleOverride, 
which will look at --patch-module to find if the given source is on any 
module patch. And it will find out it is a module patch for m2, but as 
javac never heard about m2 before, it will crash.

Seems that the biggest underlying problem is that even though javac 
knows which modules owns the class, it will try to look for the owner on 
the patch path. The proposed patch fixes that, and uses the correct 
owning module. This requires also a little cleanup in javadoc.

Webrev: cr.openjdk.java.net/~jlahoda/8217868/webrev.00/
Bug: https://bugs.openjdk.java.net/browse/JDK-8217868

How does this look?

Thanks,
     Jan


More information about the compiler-dev mailing list