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

public final Class ModuleInfoExtender

extends Object
Class Inheritance
Imports
java.io.IOException, .InputStream, .OutputStream, java.lang.constant.ClassDesc, .ModuleDesc, .PackageDesc, java.lang.module.ModuleDescriptor.Version, java.util.Collections, .List, .Set, java.lang.classfile.ClassFile, .ClassTransform, java.lang.classfile.attribute.ModuleAttribute, .ModuleHashInfo, .ModuleHashesAttribute, .ModuleMainClassAttribute, .ModulePackagesAttribute, .ModuleResolutionAttribute, .ModuleTargetAttribute

Utility class to extend a module-info.class with additional attributes.

Field Summary

Modifier and TypeField and Description
private ModuleHashes
private final InputStream
private String
private ModuleResolution
private Set<String>
private String
private ModuleDescriptor.Version

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public ModuleInfoExtender
hashes(ModuleHashes hashes)

The ModuleHashes attribute will be emitted to the module-info with the hashes encapsulated in the given ModuleHashes object.

public ModuleInfoExtender
mainClass(String mainClass)

Sets the value of the ModuleMainClass attribute.

public ModuleInfoExtender
moduleResolution(ModuleResolution mres)

Sets the value for the ModuleResolution attribute.

public static ModuleInfoExtender
newExtender(InputStream in)

Returns an Extender that may be used to add additional attributes to the module-info.class read from the given input stream.

public ModuleInfoExtender
packages(Set<String> packages)

Sets the packages for the ModulePackages attribute

public ModuleInfoExtender
targetPlatform(String targetPlatform)

Sets the value for the ModuleTarget attribute.

public byte[]
toByteArray()

Returns the bytes of the modified module-info.class.

public ModuleInfoExtender
version(ModuleDescriptor.Version version)

Sets the value for the module version in the Module attribute

public void
write(OutputStream out)

Outputs the modified module-info.class to the given output stream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

hashesback to summary
private ModuleHashes hashes
inback to summary
private final InputStream in
mainClassback to summary
private String mainClass
moduleResolutionback to summary
private ModuleResolution moduleResolution
packagesback to summary
private Set<String> packages
targetPlatformback to summary
private String targetPlatform
versionback to summary
private ModuleDescriptor.Version version

Constructor Detail

ModuleInfoExtenderback to summary
private ModuleInfoExtender(InputStream in)

Method Detail

hashesback to summary
public ModuleInfoExtender hashes(ModuleHashes hashes)

The ModuleHashes attribute will be emitted to the module-info with the hashes encapsulated in the given ModuleHashes object.

mainClassback to summary
public ModuleInfoExtender mainClass(String mainClass)

Sets the value of the ModuleMainClass attribute.

API Note

This method does not check that the main class is a legal class name in a named package.

moduleResolutionback to summary
public ModuleInfoExtender moduleResolution(ModuleResolution mres)

Sets the value for the ModuleResolution attribute.

newExtenderback to summary
public static ModuleInfoExtender newExtender(InputStream in)

Returns an Extender that may be used to add additional attributes to the module-info.class read from the given input stream.

packagesback to summary
public ModuleInfoExtender packages(Set<String> packages)

Sets the packages for the ModulePackages attribute

API Note

This method does not check that the package names are legal package names or that the set of packages is a super set of the packages in the module.

targetPlatformback to summary
public ModuleInfoExtender targetPlatform(String targetPlatform)

Sets the value for the ModuleTarget attribute.

toByteArrayback to summary
public byte[] toByteArray() throws IOException

Returns the bytes of the modified module-info.class. Once this method has been called then the Extender object should be discarded.

versionback to summary
public ModuleInfoExtender version(ModuleDescriptor.Version version)

Sets the value for the module version in the Module attribute

writeback to summary
public void write(OutputStream out) throws IOException

Outputs the modified module-info.class to the given output stream. Once this method has been called then the Extender object should be discarded.