APIdia Launch Partner
Top Description Inners Constructors Methods
jdk.internal.module

pack-priv Class ModuleReferences

extends Object
Class Inheritance
Imports
java.io.File, .IOError, .IOException, .InputStream, .UncheckedIOException, java.lang.module.ModuleReader, .ModuleReference, java.net.URI, java.nio.ByteBuffer, java.nio.file.Files, .Path, java.util.List, .Objects, .Optional, java.util.concurrent.locks.Lock, .ReadWriteLock, .ReentrantReadWriteLock, java.util.function.Supplier, java.util.jar.JarEntry, .JarFile, java.util.stream.Stream, java.util.zip.ZipFile, jdk.internal.jmod.JmodFile, jdk.internal.module.ModuleHashes.HashSupplier, sun.net.www.ParseUtil

A factory for creating ModuleReference implementations where the modules are packaged as modular JAR file, JMOD files or where the modules are exploded on the file system.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ModuleReferences.ExplodedModuleReader

A ModuleReader for an exploded module.

pack-priv static class
ModuleReferences.JarModuleReader

A ModuleReader for a modular JAR file.

pack-priv static class
ModuleReferences.JModModuleReader

A ModuleReader for a JMOD file.

pack-priv abstract static class
ModuleReferences.SafeCloseModuleReader

A base module reader that encapsulates machinery required to close the module reader safely.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static ModuleReference
newExplodedModule(ModuleInfo.Attributes attrs, ModulePatcher patcher, Path dir)

Creates a ModuleReference to a possibly-patched exploded module.

pack-priv static ModuleReference
newJarModule(ModuleInfo.Attributes attrs, ModulePatcher patcher, Path file)

Creates a ModuleReference to a possibly-patched module in a modular JAR.

pack-priv static ModuleReference
newJModModule(ModuleInfo.Attributes attrs, Path file)

Creates a ModuleReference to a module in a JMOD file.

private static ModuleReference
newModule(ModuleInfo.Attributes attrs, URI uri, Supplier<ModuleReader> supplier, ModulePatcher patcher, ModuleHashes.HashSupplier hasher)

Creates a ModuleReference to a possibly-patched module

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ModuleReferencesback to summary
private ModuleReferences()

Method Detail

newExplodedModuleback to summary
pack-priv static ModuleReference newExplodedModule(ModuleInfo.Attributes attrs, ModulePatcher patcher, Path dir)

Creates a ModuleReference to a possibly-patched exploded module.

newJarModuleback to summary
pack-priv static ModuleReference newJarModule(ModuleInfo.Attributes attrs, ModulePatcher patcher, Path file)

Creates a ModuleReference to a possibly-patched module in a modular JAR.

newJModModuleback to summary
pack-priv static ModuleReference newJModModule(ModuleInfo.Attributes attrs, Path file)

Creates a ModuleReference to a module in a JMOD file.

newModuleback to summary
private static ModuleReference newModule(ModuleInfo.Attributes attrs, URI uri, Supplier<ModuleReader> supplier, ModulePatcher patcher, ModuleHashes.HashSupplier hasher)

Creates a ModuleReference to a possibly-patched module

jdk.internal.module back to summary

pack-priv Class ModuleReferences.ExplodedModuleReader

extends Object
implements ModuleReader
Class Inheritance
All Implemented Interfaces
java.lang.module.ModuleReader, java.io.Closeable, java.lang.AutoCloseable

A ModuleReader for an exploded module.

Field Summary

Modifier and TypeField and Description
private volatile boolean
private final Path

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.module.ModuleReader.close.

Closes the module reader.

private void
ensureOpen()

Throws IOException if the module reader is closed;

public Optional<URI>
find(String name)

Implements java.lang.module.ModuleReader.find.

Finds a resource, returning a URI to the resource in the module.

public Stream<String>
list()

Implements java.lang.module.ModuleReader.list.

Lists the contents of the module, returning a stream of elements that are the names of all resources in the module.

public Optional<InputStream>
open(String name)

Overrides default java.lang.module.ModuleReader.open.

Opens a resource, returning an input stream to read the resource in the module.

public Optional<ByteBuffer>
read(String name)

Overrides default java.lang.module.ModuleReader.read.

Reads a resource, returning a byte buffer with the contents of the resource.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private volatile boolean closed
dirback to summary
private final Path dir

Constructor Detail

ExplodedModuleReaderback to summary
pack-priv ExplodedModuleReader(Path dir)

Method Detail

closeback to summary
public void close()

Implements java.lang.module.ModuleReader.close.

Doc from java.lang.module.ModuleReader.close.

Closes the module reader. Once closed then subsequent calls to locate or read a resource will fail by throwing IOException.

A module reader is not required to be asynchronously closeable. If a thread is reading a resource and another thread invokes the close method, then the second thread may block until the read operation is complete.

Annotations
@Override
ensureOpenback to summary
private void ensureOpen() throws IOException

Throws IOException if the module reader is closed;

findback to summary
public Optional<URI> find(String name) throws IOException

Implements java.lang.module.ModuleReader.find.

Doc from java.lang.module.ModuleReader.find.

Finds a resource, returning a URI to the resource in the module.

If the module reader can determine that the name locates a directory then the resulting URI will end with a slash ('/').

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
listback to summary
public Stream<String> list() throws IOException

Implements java.lang.module.ModuleReader.list.

Doc from java.lang.module.ModuleReader.list.

Lists the contents of the module, returning a stream of elements that are the names of all resources in the module. Whether the stream of elements includes names corresponding to directories in the module is module reader specific.

In lazy implementations then an IOException may be thrown when using the stream to list the module contents. If this occurs then the IOException will be wrapped in an java.io.UncheckedIOException and thrown from the method that caused the access to be attempted.

The returned stream may contain references to one or more open directories in the module. The directories are closed by closing the stream.

The behavior of the stream when used after the module reader is closed is implementation specific and therefore not specified.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
openback to summary
public Optional<InputStream> open(String name) throws IOException

Overrides default java.lang.module.ModuleReader.open.

Doc from java.lang.module.ModuleReader.open.

Opens a resource, returning an input stream to read the resource in the module.

The behavior of the input stream when used after the module reader is closed is implementation specific and therefore not specified.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
readback to summary
public Optional<ByteBuffer> read(String name) throws IOException

Overrides default java.lang.module.ModuleReader.read.

Doc from java.lang.module.ModuleReader.read.

Reads a resource, returning a byte buffer with the contents of the resource. The element at the returned buffer's position is the first byte of the resource, the element at the buffer's limit is the last byte of the resource. Once consumed, the release method must be invoked. Failure to invoke the release method may result in a resource leak.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
jdk.internal.module back to summary

pack-priv Class ModuleReferences.JarModuleReader

extends SafeCloseModuleReader
Class Inheritance

A ModuleReader for a modular JAR file.

Field Summary

Modifier and TypeField and Description
private final JarFile
private final URI

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private JarEntry
pack-priv void
pack-priv Optional<URI>
implFind(String name)

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Returns a URL to resource.

pack-priv Stream<String>
implList()

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Returns a stream of the names of resources in the module.

pack-priv Optional<InputStream>
implOpen(String name)

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Returns an input stream for reading a resource.

pack-priv static JarFile
Inherited from jdk.internal.module.ModuleReferences.SafeCloseModuleReader:
closefindlistopen

Field Detail

jfback to summary
private final JarFile jf
uriback to summary
private final URI uri

Constructor Detail

JarModuleReaderback to summary
pack-priv JarModuleReader(String path, URI uri)

Method Detail

getEntryback to summary
private JarEntry getEntry(String name)
implCloseback to summary
pack-priv void implClose() throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implClose.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implClose.

Closes the module reader. This method is invoked by close to do the actual work of closing the module reader.

Annotations
@Override
implFindback to summary
pack-priv Optional<URI> implFind(String name) throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Returns a URL to resource. This method is invoked by the find method to do the actual work of finding the resource.

Annotations
@Override
implListback to summary
pack-priv Stream<String> implList() throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Returns a stream of the names of resources in the module. This method is invoked by the list method to do the actual work of creating the stream.

Annotations
@Override
implOpenback to summary
pack-priv Optional<InputStream> implOpen(String name) throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Returns an input stream for reading a resource. This method is invoked by the open method to do the actual work of opening an input stream to the resource.

Annotations
@Override
newJarFileback to summary
pack-priv static JarFile newJarFile(String path)
jdk.internal.module back to summary

pack-priv Class ModuleReferences.JModModuleReader

extends SafeCloseModuleReader
Class Inheritance

A ModuleReader for a JMOD file.

Field Summary

Modifier and TypeField and Description
private final JmodFile
private final URI

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private JmodFile.Entry
pack-priv void
pack-priv Optional<URI>
implFind(String name)

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Returns a URL to resource.

pack-priv Stream<String>
implList()

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Returns a stream of the names of resources in the module.

pack-priv Optional<InputStream>
implOpen(String name)

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Returns an input stream for reading a resource.

pack-priv static JmodFile
Inherited from jdk.internal.module.ModuleReferences.SafeCloseModuleReader:
closefindlistopen

Field Detail

jfback to summary
private final JmodFile jf
uriback to summary
private final URI uri

Constructor Detail

JModModuleReaderback to summary
pack-priv JModModuleReader(Path path, URI uri)

Method Detail

getEntryback to summary
private JmodFile.Entry getEntry(String name)
implCloseback to summary
pack-priv void implClose() throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implClose.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implClose.

Closes the module reader. This method is invoked by close to do the actual work of closing the module reader.

Annotations
@Override
implFindback to summary
pack-priv Optional<URI> implFind(String name)

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implFind.

Returns a URL to resource. This method is invoked by the find method to do the actual work of finding the resource.

Annotations
@Override
implListback to summary
pack-priv Stream<String> implList() throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implList.

Returns a stream of the names of resources in the module. This method is invoked by the list method to do the actual work of creating the stream.

Annotations
@Override
implOpenback to summary
pack-priv Optional<InputStream> implOpen(String name) throws IOException

Implements abstract jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Doc from jdk.internal.module.ModuleReferences.SafeCloseModuleReader.implOpen.

Returns an input stream for reading a resource. This method is invoked by the open method to do the actual work of opening an input stream to the resource.

Annotations
@Override
newJmodFileback to summary
pack-priv static JmodFile newJmodFile(Path path)
jdk.internal.module back to summary

pack-priv abstract Class ModuleReferences.SafeCloseModuleReader

extends Object
implements ModuleReader
Class Inheritance
All Implemented Interfaces
java.lang.module.ModuleReader, java.io.Closeable, java.lang.AutoCloseable
Known Direct Subclasses
jdk.internal.module.ModuleReferences.JarModuleReader, jdk.internal.module.ModuleReferences.JModModuleReader

A base module reader that encapsulates machinery required to close the module reader safely.

Field Summary

Modifier and TypeField and Description
private boolean
private final ReadWriteLock
private final Lock
private final Lock

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public final void
close()

Implements java.lang.module.ModuleReader.close.

Closes the module reader.

public final Optional<URI>
find(String name)

Implements java.lang.module.ModuleReader.find.

Finds a resource, returning a URI to the resource in the module.

pack-priv abstract void
implClose()

Closes the module reader.

pack-priv abstract Optional<URI>
implFind(String name)

Returns a URL to resource.

pack-priv abstract Stream<String>
implList()

Returns a stream of the names of resources in the module.

pack-priv abstract Optional<InputStream>
implOpen(String name)

Returns an input stream for reading a resource.

public final Stream<String>
list()

Implements java.lang.module.ModuleReader.list.

Lists the contents of the module, returning a stream of elements that are the names of all resources in the module.

public final Optional<InputStream>
open(String name)

Overrides default java.lang.module.ModuleReader.open.

Opens a resource, returning an input stream to read the resource in the module.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

closedback to summary
private boolean closed
lockback to summary
private final ReadWriteLock lock
readLockback to summary
private final Lock readLock
writeLockback to summary
private final Lock writeLock

Constructor Detail

SafeCloseModuleReaderback to summary
pack-priv SafeCloseModuleReader()

Method Detail

closeback to summary
public final void close() throws IOException

Implements java.lang.module.ModuleReader.close.

Doc from java.lang.module.ModuleReader.close.

Closes the module reader. Once closed then subsequent calls to locate or read a resource will fail by throwing IOException.

A module reader is not required to be asynchronously closeable. If a thread is reading a resource and another thread invokes the close method, then the second thread may block until the read operation is complete.

Annotations
@Override
Exceptions
IOException:

Doc from java.io.Closeable.close.

if an I/O error occurs

findback to summary
public final Optional<URI> find(String name) throws IOException

Implements java.lang.module.ModuleReader.find.

Doc from java.lang.module.ModuleReader.find.

Finds a resource, returning a URI to the resource in the module.

If the module reader can determine that the name locates a directory then the resulting URI will end with a slash ('/').

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
implCloseback to summary
pack-priv abstract void implClose() throws IOException

Closes the module reader. This method is invoked by close to do the actual work of closing the module reader.

implFindback to summary
pack-priv abstract Optional<URI> implFind(String name) throws IOException

Returns a URL to resource. This method is invoked by the find method to do the actual work of finding the resource.

implListback to summary
pack-priv abstract Stream<String> implList() throws IOException

Returns a stream of the names of resources in the module. This method is invoked by the list method to do the actual work of creating the stream.

implOpenback to summary
pack-priv abstract Optional<InputStream> implOpen(String name) throws IOException

Returns an input stream for reading a resource. This method is invoked by the open method to do the actual work of opening an input stream to the resource.

listback to summary
public final Stream<String> list() throws IOException

Implements java.lang.module.ModuleReader.list.

Doc from java.lang.module.ModuleReader.list.

Lists the contents of the module, returning a stream of elements that are the names of all resources in the module. Whether the stream of elements includes names corresponding to directories in the module is module reader specific.

In lazy implementations then an IOException may be thrown when using the stream to list the module contents. If this occurs then the IOException will be wrapped in an java.io.UncheckedIOException and thrown from the method that caused the access to be attempted.

The returned stream may contain references to one or more open directories in the module. The directories are closed by closing the stream.

The behavior of the stream when used after the module reader is closed is implementation specific and therefore not specified.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed
openback to summary
public final Optional<InputStream> open(String name) throws IOException

Overrides default java.lang.module.ModuleReader.open.

Doc from java.lang.module.ModuleReader.open.

Opens a resource, returning an input stream to read the resource in the module.

The behavior of the input stream when used after the module reader is closed is implementation specific and therefore not specified.

Annotations
@Override
Exceptions
IOException:
If an I/O error occurs or the module reader is closed