Do we need to open each file on the module path to find the enclosed name?

mark.reinhold at oracle.com mark.reinhold at oracle.com
Mon Oct 5 18:52:23 UTC 2015


2015/9/28 9:54 -0700, peter.kriens at aqute.biz:
> The module path is defined as:
> 
> 	`A module path is a sequence of directories containing module
> artifacts which are searched, in order, for the first artifact that
> defines a suitable module.`
> 
> This seems to indicate that the VM must iterate over all the
> directories (I assume not recursive?)

Correct, not recursive.

>                                       and open the JARs to read the
> module-info.class file so that it knows the module name?
> 
> This seems quite expensive for large systems?

A JVM need not iterate over every directory in the module path when
searching for a module of a particular name.  It should scan each
directory in order, stopping at the first one that contains a module with
that name (and, if desired, building a cache of all the other modules
that it found).  In principle it will have to open every module artifact
in each module-path directory that it searches, since there's no
specified relationship between the name of a module and the name of an
artifact which might define it.  Some simple heuristics can be used to
avoid that in typical cases, however, since the name of a module will
often be a prefix of the name of its artifact.

With modern filesystems, even without an SSD, opening a bunch of files
in a directory and reading the first couple KB of each one can be done
pretty quickly.  (We've run some stress tests along these lines, just
to be sure.)

- Mark


More information about the jpms-spec-observers mailing list