APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.launcher

pack-priv final Record MemoryModuleFinder

extends Record
implements ModuleFinder
Class Inheritance
All Implemented Interfaces
java.lang.module.ModuleFinder
Record Components
classes:Map<String, byte[]> 
descriptor:ModuleDescriptor 
programDescriptor:ProgramDescriptor 
Imports
java.io.ByteArrayInputStream, .IOError, .IOException, .InputStream, java.lang.module.ModuleDescriptor, .ModuleFinder, .ModuleReader, .ModuleReference, java.net.URI, java.nio.ByteBuffer, java.nio.file.FileVisitOption, .Files, .Path, java.util.ArrayList, .Collections, .Map, .Optional, .Set, java.util.stream.Stream, jdk.internal.module.Resources

An in-memory module finder, that uses an in-memory cache of classes written by MemoryFileManager.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv class
pack-priv class

Field Summary

Modifier and TypeField and Description
private final Map<String, byte[]>
classes

Record Component accessed by classes().

private final ModuleDescriptor
descriptor

Record Component accessed by descriptor().

private final ProgramDescriptor
programDescriptor

Record Component accessed by programDescriptor().

Constructor Summary

AccessConstructor and Description
pack-priv
MemoryModuleFinder(Map<String, byte[]> classes, ModuleDescriptor descriptor, ProgramDescriptor programDescriptor)

Method Summary

Modifier and TypeMethod and Description
public Map<String, byte[]>
classes()

Record Component getter of classes.

public ModuleDescriptor
descriptor()

Record Component getter of descriptor.

public final boolean
equals(Object o)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public Optional<ModuleReference>
find(String name)

Implements java.lang.module.ModuleFinder.find.

Finds a reference to a module of a given name.

public Set<ModuleReference>
findAll()

Implements java.lang.module.ModuleFinder.findAll.

Returns the set of all module references that this finder can locate.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public ProgramDescriptor
programDescriptor()

Record Component getter of programDescriptor.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

classesback to summary
private final Map<String, byte[]> classes

Record Component accessed by classes().

descriptorback to summary
private final ModuleDescriptor descriptor

Record Component accessed by descriptor().

programDescriptorback to summary
private final ProgramDescriptor programDescriptor

Record Component accessed by programDescriptor().

Constructor Detail

MemoryModuleFinderback to summary
pack-priv MemoryModuleFinder(Map<String, byte[]> classes, ModuleDescriptor descriptor, ProgramDescriptor programDescriptor)

Method Detail

classesback to summary
public Map<String, byte[]> classes()

Record Component getter of classes.

descriptorback to summary
public ModuleDescriptor descriptor()

Record Component getter of descriptor.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
findback to summary
public Optional<ModuleReference> find(String name)

Implements java.lang.module.ModuleFinder.find.

Doc from java.lang.module.ModuleFinder.find.

Finds a reference to a module of a given name.

A ModuleFinder provides a consistent view of the modules that it locates. If find is invoked several times to locate the same module (by name) then it will return the same result each time. If a module is located then it is guaranteed to be a member of the set of modules returned by the findAll method.

Annotations
@Override
findAllback to summary
public Set<ModuleReference> findAll()

Implements java.lang.module.ModuleFinder.findAll.

Doc from java.lang.module.ModuleFinder.findAll.

Returns the set of all module references that this finder can locate.

A ModuleFinder provides a consistent view of the modules that it locates. If findAll is invoked several times then it will return the same (equals) result each time. For each ModuleReference element in the returned set then it is guaranteed that find will locate the ModuleReference if invoked to find that module.

Annotations
@Override
hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

programDescriptorback to summary
public ProgramDescriptor programDescriptor()

Record Component getter of programDescriptor.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

com.sun.tools.javac.launcher back to summary

pack-priv Class MemoryModuleFinder.MemoryModuleReader

extends Object
implements ModuleReader
Class Inheritance
  • java.lang.Object
  • com.sun.tools.javac.launcher.MemoryModuleFinder.MemoryModuleReader
All Implemented Interfaces
java.lang.module.ModuleReader, java.io.Closeable, java.lang.AutoCloseable

Field Summary

Modifier and TypeField and Description
private volatile boolean

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
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

Constructor Detail

MemoryModuleReaderback to summary
pack-priv MemoryModuleReader()

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.

ensureOpenback to summary
private void ensureOpen() throws IOException
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 ('/').

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.

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.

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.

Exceptions
IOException:
If an I/O error occurs or the module reader is closed
com.sun.tools.javac.launcher back to summary

pack-priv Class MemoryModuleFinder.MemoryModuleReference

extends ModuleReference
Class Inheritance

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public ModuleReader
open()

Implements abstract java.lang.module.ModuleReference.open.

Opens the module content for reading.

Inherited from java.lang.module.ModuleReference:
descriptorlocation

Constructor Detail

MemoryModuleReferenceback to summary
protected MemoryModuleReference()

Method Detail

openback to summary
public ModuleReader open()

Implements abstract java.lang.module.ModuleReference.open.

Doc from java.lang.module.ModuleReference.open.

Opens the module content for reading.

Annotations
@Override