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

Stephane Epardaud stef at epardaud.fr
Tue Mar 10 10:59:30 UTC 2015


On 09/03/15 22:04, mark.reinhold at oracle.com wrote:
> It wouldn't be hard to iterate through the class files in a module
> artifact. Iterating through the set of classes already loaded for a
> module (or by class loader) is possible but trickier. JVM TI already
> supports this [1]; does it need to be possible in a direct reflective
> API? Are there use cases which require that? 

Yes for auto-discovery if not using annotations (I see you proposed
adding annotation->class mapping to the artifacts earlier, so that would
solve discovery using annotations), such as inheritance: "give me all
types that inherit this interface".

>> 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.
> Again, are there use cases for this kind of query?
>
Yes: iterating classes is not enough: packages also hold useful
information and annotations we may want to scan. Plus, it feels more
logical that you iterate classes by iterating packages within a module,
encapsulation-wise.


More information about the jpms-spec-observers mailing list