ModuleResolutionAttribute (Java SE 22 & JDK 22)
Description: declaration: module: java.base, package: java.lang.classfile.attribute, interface: ModuleResolutionAttribute
Keywords: java.lang.classfile.attribute.ModuleResolutionAttribute interface

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

# Interface ModuleResolutionAttribute

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

public sealed interface ModuleResolutionAttribute extends AttributePREVIEW<ModuleResolutionAttributePREVIEW>, ClassElementPREVIEW
`ModuleResolutionAttribute` is a preview API of the Java platform.
Programs can only use `ModuleResolutionAttribute` 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 `ModuleResolution` attribute, which can appear on classes that represent module descriptors. This is a JDK-specific * attribute, which captures resolution metadata for modules. Delivered as a `ClassElement`PREVIEW when traversing the elements of a `ClassModel`PREVIEW.

The specification of the `ModuleResolution` attribute is:

      ModuleResolution_attribute {
        u2 attribute_name_index;    // "ModuleResolution"
        u4 attribute_length;        // 2
        u2 resolution_flags;

      The value of the resolution_flags item is a mask of flags used to denote
      properties of module resolution. The flags are as follows:

       // Optional
       0x0001 (DO_NOT_RESOLVE_BY_DEFAULT)

       // At most one of:
       0x0002 (WARN_DEPRECATED)
       0x0004 (WARN_DEPRECATED_FOR_REMOVAL)
       0x0008 (WARN_INCUBATING)
      }

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
  `static ModuleResolutionAttributePREVIEW`
  `of(int resolutionFlags)`
  Returns a `ModuleResolution` attribute.
  `int`
  `resolutionFlags()`
  The value of the resolution_flags item is a mask of flags used to denote properties of module resolution.

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

  `attributeMapper, attributeName`

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

  `writeTo`

- ## Method Details

  - ### resolutionFlags

    int resolutionFlags()
    The value of the resolution_flags item is a mask of flags used to denote properties of module resolution. The flags are as follows:

           // Optional
           0x0001 (DO_NOT_RESOLVE_BY_DEFAULT)

           // At most one of:
           0x0002 (WARN_DEPRECATED)
           0x0004 (WARN_DEPRECATED_FOR_REMOVAL)
           0x0008 (WARN_INCUBATING)

    Returns:
      the module resolution flags

  - ### of

    static ModuleResolutionAttributePREVIEW of(int resolutionFlags)
    Returns a `ModuleResolution` attribute.
    Parameters:
      `resolutionFlags` - the resolution flags
    Returns:
      a `ModuleResolution` attribute