Top Description Fields Constructors Methods
java.lang.module

public abstract Class ModuleReference

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.module.ModuleReferenceImpl
Imports
java.io.IOException, java.net.URI, java.util.Objects, .Optional

A reference to a module's content.

A module reference is a concrete implementation of this class that implements the abstract methods defined by this class. It contains the module's descriptor and its location, if known. It also has the ability to create a ModuleReader in order to access the module's content, which may be inside the Java run-time system itself or in an artifact such as a modular JAR file.

Since
9
See Also
ModuleFinder, ModuleReader

Field Summary

Modifier and TypeField and Description
private final ModuleDescriptor
private final URI

Constructor Summary

AccessConstructor and Description
protected
ModuleReference(ModuleDescriptor
The module descriptor
descriptor
,
URI
The module location or null if not known
location
)

Constructs a new instance of this class.

Method Summary

Modifier and TypeMethod and Description
public final ModuleDescriptor

Returns:

The module descriptor
descriptor
()

Returns the module descriptor.

public final Optional<URI>

Returns:

The location or an empty Optional if not known
location
()

Returns the location of this module's content, if known.

public abstract ModuleReader

Returns:

A ModuleReader to read the module
open
()

Opens the module content for reading.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

descriptorback to summary
private final ModuleDescriptor descriptor
locationback to summary
private final URI location

Constructor Detail

ModuleReferenceback to summary
protected ModuleReference(ModuleDescriptor descriptor, URI location)

Constructs a new instance of this class.

Parameters
descriptor:ModuleDescriptor

The module descriptor

location:URI

The module location or null if not known

Method Detail

descriptorback to summary
public final ModuleDescriptor descriptor()

Returns the module descriptor.

Returns:ModuleDescriptor

The module descriptor

locationback to summary
public final Optional<URI> location()

Returns the location of this module's content, if known.

This URI, when present, can be used as the location value of a CodeSource so that a module's classes can be granted specific permissions when loaded by a SecureClassLoader.

Returns:Optional<URI>

The location or an empty Optional if not known

openback to summary
public abstract ModuleReader open() throws IOException

Opens the module content for reading.

Returns:ModuleReader

A ModuleReader to read the module

Exceptions
IOException:
If an I/O error occurs
SecurityException:
If denied by the security manager