Module java.base
Package java.lang.classfile.attributePREVIEW

# Interface ModuleHashesAttribute

All Superinterfaces:
  `AttributePREVIEW<ModuleHashesAttributePREVIEW>`, `ClassElementPREVIEW`, `ClassFileElementPREVIEW`, `WritableElementPREVIEW<ModuleHashesAttributePREVIEW>`

public sealed interface ModuleHashesAttribute extends AttributePREVIEW<ModuleHashesAttributePREVIEW>, ClassElementPREVIEW
`ModuleHashesAttribute` is a preview API of the Java platform.
Programs can only use `ModuleHashesAttribute` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models the `ModuleHashes` attribute, which can appear on classes that represent module descriptors. This is a JDK-specific attribute, which captures the hashes of a set of co-delivered modules. Delivered as a `ClassElement`PREVIEW when traversing the elements of a `ClassModel`PREVIEW.

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

     }

The attribute does not permit multiple instances in a given location. Subsequent occurrence of the attribute takes precedence during the attributed element build or transformation.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Utf8EntryPREVIEW`
  `algorithm()`
  Returns the algorithm name used to compute the hash.
  `List<ModuleHashInfoPREVIEW>`
  `hashes()`
  Returns the hash information about related modules.
  `static ModuleHashesAttributePREVIEW`
  `of(Utf8EntryPREVIEW algorithm, ModuleHashInfoPREVIEW... hashes)`
  Returns a `ModuleHashes` attribute.
  `static ModuleHashesAttributePREVIEW`
  `of(Utf8EntryPREVIEW algorithm, List<ModuleHashInfoPREVIEW> hashes)`
  Returns a `ModuleHashes` attribute.
  `static ModuleHashesAttributePREVIEW`
  `of(String algorithm, ModuleHashInfoPREVIEW... hashes)`
  Returns a `ModuleHashes` attribute.
  `static ModuleHashesAttributePREVIEW`
  `of(String algorithm, List<ModuleHashInfoPREVIEW> hashes)`
  Returns a `ModuleHashes` attribute.

  ### Methods declared in interface java.lang.classfile.AttributePREVIEW

  `attributeMapper, attributeName`

  ### Methods declared in interface java.lang.classfile.WritableElementPREVIEW

  `writeTo`

- ## Method Details

  - ### algorithm

    Utf8EntryPREVIEW algorithm()
    Returns the algorithm name used to compute the hash.
    Returns:
      the algorithm name used to compute the hash

  - ### hashes

    List<ModuleHashInfoPREVIEW> hashes()
    Returns the hash information about related modules.
    Returns:
      the hash information about related modules

  - ### of

    static ModuleHashesAttributePREVIEW of(String algorithm, List<ModuleHashInfoPREVIEW> hashes)
    Returns a `ModuleHashes` attribute.
    Parameters:
      `algorithm` - the hashing algorithm
      `hashes` - the hash descriptions
    Returns:
      a `ModuleHashes` attribute

  - ### of

    static ModuleHashesAttributePREVIEW of(String algorithm, ModuleHashInfoPREVIEW... hashes)
    Returns a `ModuleHashes` attribute.
    Parameters:
      `algorithm` - the hashing algorithm
      `hashes` - the hash descriptions
    Returns:
      a `ModuleHashes` attribute

  - ### of

    static ModuleHashesAttributePREVIEW of(Utf8EntryPREVIEW algorithm, List<ModuleHashInfoPREVIEW> hashes)
    Returns a `ModuleHashes` attribute.
    Parameters:
      `algorithm` - the hashing algorithm
      `hashes` - the hash descriptions
    Returns:
      a `ModuleHashes` attribute

  - ### of

    static ModuleHashesAttributePREVIEW of(Utf8EntryPREVIEW algorithm, ModuleHashInfoPREVIEW... hashes)
    Returns a `ModuleHashes` attribute.
    Parameters:
      `algorithm` - the hashing algorithm
      `hashes` - the hash descriptions
    Returns:
      a `ModuleHashes` attribute