RFR: JDK-8220702: compiling in the context of an automatic module disallows --add-modules ALL-MODULE-PATH

Jan Lahoda jan.lahoda at oracle.com
Fri Apr 12 12:34:12 UTC 2019

On 11. 04. 19 20:28, Alex Buckley wrote:
> On 4/11/2019 1:19 AM, Jan Lahoda wrote:
>> Yes, I think JEP 261 may need updates. I'd say this is somewhat
>> unforeseen interaction between automatic modules and --patch-module.
>> When patching a (named) module (or a set of named modules), that module
>> (or modules) become the root module for javac, and the ordinary module
>> graph building algorithm is then used to build the module graph. So the
>> set of modules in the module graph may be different from the set of the
>> modules in the module graph when compiling source in the unnamed module.
> OK. It sounds like (i) single-module mode supports source files being 
> compiled as if members of a named module (the module being patched), and 
> (ii) multi-module mode supports source files being compiled as if 
> members of named modules (the modules being patched). Great.
> Broadly, JEP 261 is correct when it says this in "Root modules":
> -----
> Otherwise, the default set of root modules depends upon the phase:
> - At compile time it is usually the set of modules being compiled (more 
> on this below);
> -----
> where "below", it is correct for multi-module mode:
> -----
> The set of root modules is the set of modules for which at least one 
> source file is specified.
> -----
> but incorrect for single-module mode: (assuming javac is invoked as 
> shown in your first mail)
> -----
> Otherwise source files will be compiled as members of the unnamed 
> module, and the root modules will be computed as described above.
> -----
> JEP 261 is the ultimate source of truth for the module system, from 
> which all tutorials, blogs, books, etc derive. It's very hard to infer 
> from it that javac supports compiling source as if in a patched module. 
> That's why a CSR to record what javac does (either with no --add-modules 
> or with --add-modules=ALL-MODULE-PATH) will be so valuable. In advance 
> of that, can you share some detailed invocations of javac using 
> --patch-module in single-module and multi-module mode?

I've started with the CSR here:

Consider a directory "path" that contains "automatic.jar", which does 
not have a module-info.class, and "explicit.jar" which has 
module-info.class. The a compilation in multi-module mode might look 
like this:
$ javac -d out --patch-module automatic=test/automatic/src 
--patch-module explicit=test/explicit/src --module-path path 
--module-source-path dummy 

A compilation in single-module mode might look like:
$ javac -d out --patch-module explicit=test/explicit/src --module-path 
path test/explicit/src/explicit/ExplicitTest.java


> Alex

More information about the compiler-dev mailing list