Compiling with automatic modules

Stephan Herrmann stephan.herrmann at
Tue May 23 20:47:07 UTC 2017

On 23.05.2017 22:30, Alex Buckley wrote:
> On 5/23/2017 12:54 PM, Stephan Herrmann wrote:
>> The 2017-05-18 draft of JLS indicates that automatic modules are beyond the
>> scope of JLS.
>> I'm puzzled what that should mean for a compiler.
>> At face value it seems to say that compilers need not care about automatic
>> modules. Instead I'd expect JLS to state that the host system must be able
>> to discover automatic modules "as if by invocation of
>> ModuleFinder.of(Path...)." or similar.
>> Which is it?
> Can you quote the text of concern?

JLS 7.7:
   "The Java programming language does not distinguish between (i) named modules specified
    explicitly in module declarations and (ii) named modules specified implicitly by the Java
    Platform Module System, that is, automatic modules. A module declaration refers to other
    named modules without being aware of the manner in which they were specified."

> Automatic modules are not a source artifact, so their specification is found in the API portion of the JPMS spec rather than in the 
> JLS. The JLS has traditionally not specified how a compiler interprets non-source artifacts, e.g., the JLS says nothing about 
> whether the host system understands a "class path" or that such a thing might identify non-source artifacts like JAR files. The 
> analog in the Java SE 9 era is that it's up to a compiler to choose to support a thing called the "module path" and to identify 
> non-source artifacts on it; I do not see how the JLS can say anything for that. Once a compiler has made the choice, then the JPMS 
> specifies that certain non-source artifacts must be interpreted as automatic modules, at which point they're "just" named modules 
> that a modular compilation unit's 'requires' directive can refer to.

There's a decisive difference: for .class files (in the file system or in a .jar)
the compiler "knows" what it means, because .class files are well in the realm of
compilers. There are no hidden semantics.

A jar-as-automatic-module has semantics that are not known to the compiler,
unless JLS specifies s.t. to this end.

I wasn't concerned about the module-path aspect of it, just about the semantics of
those modules for which no descriptor exists.


More information about the jigsaw-dev mailing list