APIdia Launch Partner
Top Description Methods
java.lang.classfile.attribute

public sealed Interface ModuleHashesAttribute

extends Attribute<ModuleHashesAttribute>, ClassElement
permits BoundModuleHashesAttribute, UnboundModuleHashesAttribute
Known Direct Implementers
jdk.internal.classfile.impl.BoundAttribute.BoundModuleHashesAttribute, jdk.internal.classfile.impl.UnboundAttribute.UnboundModuleHashesAttribute
Imports
java.lang.classfile.Attribute, .AttributeMapper, .AttributeMapper.AttributeStability, .Attributes, .ClassElement, .ClassModel, java.lang.classfile.constantpool.Utf8Entry, java.util.List, jdk.internal.classfile.impl.BoundAttribute, .TemporaryConstantPool, .UnboundAttribute

Models the ModuleHashes attribute, which appears on classes that represent module descriptors to capture the hashes of a set of co-delivered modules.

The specification of the ModuleHashes attribute is:

 ModuleHashes_attribute {
  // index to CONSTANT_utf8_info structure in constant pool representing
  // the string "ModuleHashes"
  u2 attribute_name_index;
  u4 attribute_length;

  // index to CONSTANT_utf8_info structure with algorithm name
  u2 algorithm_index;

  // the number of entries in the hashes table
  u2 hashes_count;
  {   u2 module_name_index (index to CONSTANT_Module_info structure)
      u2 hash_length;
      u1 hash[hash_length];
  } hashes[hashes_count];

}
 

This attribute only appears on classes, and does not permit multiple instances in a class. It has a data dependency on the constant pool.

This attribute is not predefined in the Java SE Platform. This is a JDK-specific nonstandard attribute produced by the jdk.jlink module, which defines the jlink and jmod tools.

Since
24
See Also
Attributes#moduleHashes(), ModuleResolutionAttribute, ModuleTargetAttribute

Method Summary

Modifier and TypeMethod and Description
public Utf8Entry

Returns:

the algorithm name used to compute the hash
algorithm
()

Returns the algorithm name used to compute the hash.

public List<ModuleHashInfo>

Returns:

the hash information about related modules
hashes
()

Returns the hash information about related modules.

public static ModuleHashesAttribute

Returns:

a ModuleHashes attribute
of
(String
the hashing algorithm
algorithm
,
List<ModuleHashInfo>
the hash descriptions
hashes
)

Returns a ModuleHashes attribute.

public static ModuleHashesAttribute

Returns:

a ModuleHashes attribute
of
(String
the hashing algorithm
algorithm
,
ModuleHashInfo...
the hash descriptions
hashes
)

Returns a ModuleHashes attribute.

public static ModuleHashesAttribute

Returns:

a ModuleHashes attribute
of
(Utf8Entry
the hashing algorithm
algorithm
,
List<ModuleHashInfo>
the hash descriptions
hashes
)

Returns a ModuleHashes attribute.

public static ModuleHashesAttribute

Returns:

a ModuleHashes attribute
of
(Utf8Entry
the hashing algorithm
algorithm
,
ModuleHashInfo...
the hash descriptions
hashes
)

Returns a ModuleHashes attribute.

Inherited from java.lang.classfile.Attribute:
attributeMapperattributeName

Method Detail

algorithmback to summary
public Utf8Entry algorithm()

Returns the algorithm name used to compute the hash.

Returns:Utf8Entry

the algorithm name used to compute the hash

hashesback to summary
public List<ModuleHashInfo> hashes()

Returns the hash information about related modules.

Returns:List<ModuleHashInfo>

the hash information about related modules

ofback to summary
public static ModuleHashesAttribute of(String algorithm, List<ModuleHashInfo> hashes)

Returns a ModuleHashes attribute.

Parameters
algorithm:String

the hashing algorithm

hashes:List<ModuleHashInfo>

the hash descriptions

Returns:ModuleHashesAttribute

a ModuleHashes attribute

Exceptions
IllegalArgumentException:
if the number of descriptions exceeds the limit of u2
ofback to summary
public static ModuleHashesAttribute of(String algorithm, ModuleHashInfo... hashes)

Returns a ModuleHashes attribute.

Parameters
algorithm:String

the hashing algorithm

hashes:ModuleHashInfo[]

the hash descriptions

Returns:ModuleHashesAttribute

a ModuleHashes attribute

Exceptions
IllegalArgumentException:
if the number of descriptions exceeds the limit of u2
ofback to summary
public static ModuleHashesAttribute of(Utf8Entry algorithm, List<ModuleHashInfo> hashes)

Returns a ModuleHashes attribute.

Parameters
algorithm:Utf8Entry

the hashing algorithm

hashes:List<ModuleHashInfo>

the hash descriptions

Returns:ModuleHashesAttribute

a ModuleHashes attribute

Exceptions
IllegalArgumentException:
if the number of descriptions exceeds the limit of u2
ofback to summary
public static ModuleHashesAttribute of(Utf8Entry algorithm, ModuleHashInfo... hashes)

Returns a ModuleHashes attribute.

Parameters
algorithm:Utf8Entry

the hashing algorithm

hashes:ModuleHashInfo[]

the hash descriptions

Returns:ModuleHashesAttribute

a ModuleHashes attribute

Exceptions
IllegalArgumentException:
if the number of descriptions exceeds the limit of u2