what if module-info missing?

Jonathan Gibbons Jonathan.Gibbons at Sun.COM
Thu Dec 10 16:48:26 PST 2009


What is the desired behavior if module-info is missing in a place where 
it might reasonably be expected to exist?

In the context of javac, there are two cases to consider:
1) in single module mode, the "current" module
2) all other modules

For (1), it is acceptable for the "current" module not to have 
module-info -- it just means the user is not compiling a module, as 
such.  More pedantically, the user is compiling code in the unnamed 
module with a single default dependency on the java platform.

So the interesting case is all other modules, whether they are on the 
modulepath, or on the sourcepath in multi-module mode.

Here are some of the options we can choose from
a) ignore directories on the modulepath that do not contain module-info
b) infer the contents of module-info from the directory name:  " module 
/dir-name /{ }"
c) give a warning about directories that do not contain module-info, and 
otherwise ignore it
d) give a warning if -Xlint:path is specified, and otherwise ignore it
e) give an error

Ignoring stuff which might be an error is generally bad, so that rules 
out (a) and to some extent, (d) as well. Inferring the contents is 
little better that guessing, so that rules out (b),  leaving (c) give a 
warning and (e) give an error.

I propose that both of them may be appropriate, depending on the 
circumstances.

When we are scanning the module path or source path to see what modules 
are available, if we come across a directory without a module-info, it 
is arguably sufficient to give a warning and keep on going. To give an 
error at that point will prevent any further progress in the 
compilation. (Note that we are dealing with paths here, so when talking 
about a directory without module-info, that really means no module-info 
in any directory of the same name on the path.)

However, if we are examining files on the command line in multi-module 
mode, we *need* a module-info to determine the module for the 
compilation unit on the command line. If the module-info is missing in 
this case, we cannot determine the set of classes visible to that 
compilation unit, so in this case an error is definitely in order.

Comments?

-- Jon



More information about the jigsaw-dev mailing list