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

Jan Lahoda jan.lahoda at oracle.com
Thu Apr 11 08:19:42 UTC 2019


On 11. 04. 19 0:19, Jonathan Gibbons wrote:
> 
> On 4/10/19 3:07 PM, Alex Buckley wrote:
>> On 4/10/2019 2:51 PM, Jonathan Gibbons wrote:
>>> On 4/10/19 11:51 AM, Alex Buckley wrote:
>>>> There is a question to be answered: When the compiler compiles code in
>>>> an automatic module (due to the code being observed in a directory
>>>> that is specified to --patch-module), then what is the _default set of
>>>> root modules_ for the automatic module?
>>>>
>>>> I expect the answer is: the same as the default set of root modules
>>>> for the unnamed module.
>>>
>>> I would not expect the fact that you're compiling code in one or more
>>> automatic modules to have any effect on the module graph. The fact that
>>> the definitions of some types have been "patched in" using source code
>>> via --patch-module is (or should be) irrelevant.
>>
>> I'm not sure how anyone compiles code as if in an automatic module, 
>> since the automatic module is solely a JAR file, but Jan suggests that 
>> it's possible to patch an automatic module's content with the source 
>> files being compiled. So, I looked in JEP 261 to see how javac would 
>> treat those source files:
>>
>> "If a module descriptor in the form of a module-info.java or 
>> module-info.class file is specified on the command line [NO], or is 
>> found on the source path [NO] or the class path [NO], then source 
>> files will be compiled as members of the module named by that 
>> descriptor and that module will be the sole root module. Otherwise if 
>> the --module <module> option is present [NO] then source files will be 
>> compiled as members of <module>, which will be the root module. 
>> Otherwise [I GUESS WE'RE HERE] source files will be compiled as 
>> members of the unnamed module, and the root modules will be computed 
>> as described above."
>>
>> Alex
> 
> It sounds like JEP 261 should be updated with more info about patching 
> modules, since "you are not here" where you guess we are.

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.

Jan

> 
> At compilation time, --patch-module allows any content to be "patched 
> in" to any module in the module graph. The content may be provided in 
> source form or compiled form. In either case, the context for any names 
> mentioned in the content is determined by the module being patched, and 
> its dependencies.
> 
> -- Jon
> 


More information about the jigsaw-dev mailing list