Module java.base
Package java.lang.classfile

# Enum ClassFile.StackMapsOption

≠
public static final enum StackMapsOption
extends java.lang.Enum<java.lang.classfile.ClassFile.StackMapsOption>
implements java.lang.classfile.ClassFile.Option
Comparing master and cf

All Implemented Interfaces:
  `Serializable, ClassFile.Option, Comparable<ClassFile.StackMapsOption>, Constable`

Enclosing interface:
  `ClassFile`

public static enum ClassFile.StackMapsOption extends Enum<ClassFile.StackMapsOption> implements ClassFile.Option
Option The option describing whether to generate stackmapsstack maps. Default The default is `Moved to a link with destination #STACK_MAPS_WHEN_REQUIRED.STACK_MAPS_WHEN_REQUIRED` Moved to a link with destination #STACK_MAPS_WHEN_REQUIRED. to generate stack maps for `ClassFile.JAVA_6_VERSION` or above, where specifically for `ClassFile.JAVA_6_VERSION` the stack maps may not be generatedor reuse existing ones if compatible.

The `StackMapTableAttribute` is a derived property from a `Code` attribute to allow a Java Virtual Machine to perform verification in one pass. Thus, it is not modeled as part of a `CodeModel` , but computed on-demand instead via stack maps generation.

Stack map generation may fail with an `IllegalArgumentException` if there is unreachable code or legacy jump routine instructions. When `DROP_STACK_MAPS` option is used, users can provide their own stack maps by supplying a `StackMapTableAttribute` to a `CodeBuilder` Moved to a paragraph..

See Java Virtual Machine Specification:
  4.10.1 Verification by Type Checking
Since:
  24
See Also:
  Moved to a definition list with class notes.Moved to a definition.Moved to an unordered list with class tag-list.
  - `StackMapTableAttribute`
  - `ClassFile.DeadCodeOption`

## Enum Constants

- ≠
  DROP_STACK_MAPS
  Comparing master and cf

  ### DROP_STACK_MAPS

  public static final ClassFile.StackMapsOption DROP_STACK_MAPS
  Do not run stack map generation. Users must supply their own `StackMapTableAttribute` to a `CodeBuilder` if the code has branches or exception handlers; otherwise, the generated code will fail verification (JVMS 4.10.1).

  This option is required for user-supplied `StackMapTableAttribute` to be respected. Stack maps on an existing `Code` attribute can be reused as below with this option:

      CodeAttribute code = method.findAttribute(Attributes.code()).orElseThrow();
      // Note that StackMapTable may be absent, representing code with no branching
      code.findAttribute(Attributes.stackMapTable()).ifPresent(cob);

  Drop stack maps from code

      Moved to a division with class snippet-container.Moved to a preformatted block with class snippet and id snippet-DROP_STACK_MAPS1.

  Moved to a division with class snippet-container.Moved to a preformatted block with class snippet and id snippet-DROP_STACK_MAPS1.
- ≠
  GENERATE_STACK_MAPS
  Comparing master and cf

  ### GENERATE_STACK_MAPS

  public static final ClassFile.StackMapsOption GENERATE_STACK_MAPS
  Always generate stack mapsForces running stack map generation. This runs stack map generation unconditionally and fails fast if the generation fails due to any reason.
- ≠
  STACK_MAPS_WHEN_REQUIRED
  Comparing master and cf

  ### STACK_MAPS_WHEN_REQUIRED

  public static final ClassFile.StackMapsOption STACK_MAPS_WHEN_REQUIRED
  Generate stack maps when requiredor reuse existing ones if compatible. Stack maps are present on major versions 50 or above. For these versions, `CodeBuilder` tries to reuse compatible stack maps information if the code array and exception handlers are still compatible after a transformation; otherwise, it runs stack map generation. However, it does not fail fast if the major version is 50, which allows jump subroutine instructions that are incompatible with stack maps to exist in the `code` array.

## Methods

- =
  public static java.lang.classfile.ClassFile.StackMapsOption valueOf(java.lang.String arg0)
- =
  public static java.lang.classfile.ClassFile.StackMapsOption[] values()

## Summary

Differences
| Elements | Comments | Descriptions | Total
Added | Changed | Removed | Added | Changed | Removed | Added | Changed | Removed
--- | --- | --- | --- | --- | --- | --- | --- | ---
ClassFile.StackMapsOption |  |  |  |  |  |  | 11 | 7 | 2 | 20
DROP_STACK_MAPS |  |  |  |  |  |  | 7 | 1 | 1 | 9
GENERATE_STACK_MAPS |  |  |  |  |  |  |  | 1 |  | 1
STACK_MAPS_WHEN_REQUIRED |  |  |  |  |  |  | 4 | 1 |  | 5
Total |  |  |  |  |  |  | 22 | 10 | 3 | 35