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

public final Class ModuleInfo

extends Object
Class Inheritance
Imports
java.io.DataInput, .DataInputStream, .EOFException, .IOException, .InputStream, .UncheckedIOException, java.lang.classfile.ClassFile, java.lang.module.InvalidModuleDescriptorException, .ModuleDescriptor, .ModuleDescriptor.Builder, .ModuleDescriptor.Requires, .ModuleDescriptor.Exports, .ModuleDescriptor.Opens, java.nio.ByteBuffer, .BufferUnderflowException, java.util.ArrayList, .HashMap, .HashSet, .List, .Map, .Set, java.util.function.Supplier, jdk.internal.access.JavaLangModuleAccess, .SharedSecrets, jdk.internal.misc.VM

Read module information from a module-info class file.

Implementation Note

The rationale for the hand-coded reader is startup performance and fine control over the throwing of InvalidModuleDescriptorException.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ModuleInfo.Attributes

A holder class for the ModuleDescriptor that is created by reading the Module and other standard class file attributes.

private static class
ModuleInfo.ConstantPool

The constant pool in a class file.

private static class
ModuleInfo.CountingDataInput

A DataInput implementation that reads from another DataInput and counts the number of bytes read.

private static class
ModuleInfo.DataInputWrapper

A DataInput implementation that reads from a ByteBuffer.

Field Summary

Modifier and TypeField and Description
private static final JavaLangModuleAccess
private final Supplier<Set<String>>
private final boolean
private static volatile Set<String>

Constructor Summary

AccessConstructor and Description
private
ModuleInfo(Supplier<Set<String>> pf, boolean ph)

private

Method Summary

Modifier and TypeMethod and Description
private ModuleInfo.Attributes
doRead(DataInput input)

Reads the input as a module-info class file.

private static InvalidModuleDescriptorException
invalidModuleDescriptor(String msg)

Returns an InvalidModuleDescriptorException with the given detail message

private static boolean
isAttributeAtMostOnce(String name)

Returns true if the given attribute can be present at most once in the class file.

private static boolean
isAttributeDisallowed(String name)

Return true if the given attribute name is the name of a pre-defined attribute in JVMS 4.7 that is not allowed in a module-info class.

public static ModuleInfo.Attributes
read(InputStream in, Supplier<Set<String>> pf)

Reads a module-info.class from the given input stream.

public static ModuleInfo.Attributes
read(ByteBuffer bb, Supplier<Set<String>> pf)

Reads a module-info.class from the given byte buffer.

public static ModuleInfo.Attributes
readIgnoringHashes(ByteBuffer bb, Supplier<Set<String>> pf)

Reads a module-info.class from the given byte buffer but ignore the ModuleHashes attribute.

private ModuleDescriptor.Builder
readModuleAttribute(DataInput in, ModuleInfo.ConstantPool cpool, int major, boolean isPreview)

Reads the Module attribute, returning the ModuleDescriptor.Builder to build the corresponding ModuleDescriptor.

private ModuleHashes
readModuleHashesAttribute(DataInput in, ModuleInfo.ConstantPool cpool)

Reads the ModuleHashes attribute

private String
readModuleMainClassAttribute(DataInput in, ModuleInfo.ConstantPool cpool)

Reads the ModuleMainClass attribute

private Set<String>
readModulePackagesAttribute(DataInput in, ModuleInfo.ConstantPool cpool)

Reads the ModulePackages attribute

private ModuleResolution
readModuleResolution(DataInput in, ModuleInfo.ConstantPool cpool)

Reads the ModuleResolution attribute.

private ModuleTarget
readModuleTargetAttribute(DataInput in, ModuleInfo.ConstantPool cpool)

Reads the ModuleTarget attribute

private static InvalidModuleDescriptorException
truncatedModuleDescriptor()

Returns an InvalidModuleDescriptorException with a detail message to indicate that the class file is truncated.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait