ModuleReader (Java SE 10 & JDK 10 )
Provides access to the content of a module.
A module reader is intended for cases where access to the resources in a
module is required, regardless of whether the module has been loaded.
A framework that scans a collection of packaged modules on the file system,
for example, may use a module reader to access a specific resource in each
module. A module reader is also intended to be used by ClassLoader
implementations that load classes and resources from modules.
A resource in a module is identified by an abstract name that is a
'/'-separated path string. For example, module java.base may
have a resource "java/lang/Object.class" that, by convention, is the
class file for java.lang.Object. A module reader may treat
directories in the module content as resources (whether it does or not is
module reader specific). Where the module content contains a directory
that can be located as a resource then its name ends with a slash ('/'). The
directory can also be located with a name that drops the trailing slash.
A ModuleReader is open upon
creation and is closed by invoking the close method. Failure
to close a module reader may result in a resource leak. The
try-with-resources statement provides a useful construct to ensure that
module readers are closed.
A ModuleReader implementation may require permissions to access
resources in the module. Consequently the find, open, read, and list methods may throw
SecurityException if access is denied by the security manager.