Module, Class, and Resource Iteration (Was: Re: Module-system requirements)

David M. Lloyd david.lloyd at
Wed Feb 25 19:01:49 UTC 2015

One thing that is missing from the requirements is the ability to 
iterate or enumerate modules, classes, and/or resources.  This is one 
capability that people seem to be assuming will be magically provided by 
a module solution.

While it seems to me that resource or resource directory iteration is 
(modulo the discussion on the "Exporting things" sub-thread) easily 
accomplished, defining the meaning of module iteration and class 
iteration is a little bit more involved.

To iterate modules implies that the configuration has a complete picture 
of all the modules it can load, and that it can iterate over this 
picture in a relatively inexpensive manner.  This is probably 
reasonable, though in my imagination I see that the set of available 
modules may change over time within the life of a single VM process.

Iterating classes is a stranger expectation though, because while it is 
a reasonable inclination to want to try this, it is possibly actively 
harmful to start loading previously-unloaded classes.  So such a 
function would either need to restrict its output set to loaded classes, 
or do something else like just enumerate class names.  In addition, 
there are security considerations to take into account; a caller should 
only "see" classes that are accessible to it (though things like 
frameworks may need an elevated capability in order to introspect 
non-public classes).

Another potentially iterable "thing" is packages, either in the form of 
names or Package objects.  No comment on the applicability or lack 
thereof of such a capability though.


More information about the jpms-spec-observers mailing list