CharacterRange (Java SE 25 & JDK 25)
Description: declaration: module: java.base, package: java.lang.classfile.instruction, interface: CharacterRange
Keywords: java.lang.classfile.instruction.CharacterRange interface

# Interface CharacterRange

All Superinterfaces:
  `ClassFileElement, CodeElement, PseudoInstruction`

public sealed interface CharacterRange extends PseudoInstruction
A pseudo-instruction which models a single entry in the `CharacterRangeTable` attribute. Delivered as a `CodeElement` during traversal of the elements of a `CodeModel`, according to the setting of the `ClassFile.DebugElementsOption` option.

A character range entry is composite:

    CharacterRange(
        Label startScope,
        Label endScope,
        int characterRangeStart,
        int characterRangeEnd,
        int flags
    )

Another model, `CharacterRangeInfo`, also models a character range entry; it has no dependency on a `CodeModel` and represents of bci values as `int`s instead of `Label`s, and is used as components of a `CharacterRangeTableAttribute`.

Since:
  24
See Also:
  - `CharacterRangeInfo`
  - `CodeBuilder::characterRange`
  - `ClassFile.DebugElementsOption`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `FLAG_ASSIGNMENT`
  The bit mask of ASSIGNMENT `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_BLOCK`
  The bit mask of BLOCK `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_BRANCH_FALSE`
  The bit mask of BRANCH_FALSE `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_BRANCH_TRUE`
  The bit mask of BRANCH_TRUE `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_CREATE`
  The bit mask of CREATE `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_FLOW_CONTROLLER`
  The bit mask of FLOW_CONTROLLER `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_FLOW_TARGET`
  The bit mask of FLOW_TARGET `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_INVOKE`
  The bit mask of INVOKE `CharacterRangeInfo` kind.
  `static final int`
  `FLAG_STATEMENT`
  The bit mask of STATEMENT `CharacterRangeInfo` kind.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `characterRangeEnd()`
  Returns the encoded end of the character range region (exclusive).
  `int`
  `characterRangeStart()`
  Returns the encoded start of the character range region (inclusive).
  `Label`
  `endScope()`
  Returns the end of the instruction range.
  `int`
  `flags()`
  A flags word, indicating the kind of range.
  `static CharacterRange`
  `of(Label startScope, Label endScope, int characterRangeStart, int characterRangeEnd, int flags)`
  Returns a character range pseudo-instruction.
  `Label`
  `startScope()`
  Returns the start of the instruction range.

- ## Field Details

  - ### FLAG_STATEMENT

    static final int FLAG_STATEMENT
    The bit mask of STATEMENT `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_BLOCK

    static final int FLAG_BLOCK
    The bit mask of BLOCK `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_ASSIGNMENT

    static final int FLAG_ASSIGNMENT
    The bit mask of ASSIGNMENT `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_FLOW_CONTROLLER

    static final int FLAG_FLOW_CONTROLLER
    The bit mask of FLOW_CONTROLLER `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_FLOW_TARGET

    static final int FLAG_FLOW_TARGET
    The bit mask of FLOW_TARGET `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_INVOKE

    static final int FLAG_INVOKE
    The bit mask of INVOKE `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_CREATE

    static final int FLAG_CREATE
    The bit mask of CREATE `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_BRANCH_TRUE

    static final int FLAG_BRANCH_TRUE
    The bit mask of BRANCH_TRUE `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

  - ### FLAG_BRANCH_FALSE

    static final int FLAG_BRANCH_FALSE
    The bit mask of BRANCH_FALSE `CharacterRangeInfo` kind.
    See Also:
      - Constant Field Values

- ## Method Details

  - ### startScope

    Label startScope()
    Returns the start of the instruction range.
    Returns:
      the start of the instruction range

  - ### endScope

    Label endScope()
    Returns the end of the instruction range.
    Returns:
      the end of the instruction range

  - ### characterRangeStart

    int characterRangeStart()
    Returns the encoded start of the character range region (inclusive). The value is constructed from the line_number/column_number pair as given by `line_number << 10 + column_number`, where the source file is viewed as an array of (possibly multi-byte) characters.
    Returns:
      the encoded start of the character range region (inclusive)

  - ### characterRangeEnd

    int characterRangeEnd()
    Returns the encoded end of the character range region (exclusive).. The value is constructed from the line_number/column_number pair as given by `line_number << 10 + column_number`, where the source file is viewed as an array of (possibly multi-byte) characters.
    Returns:
      the encoded end of the character range region (exclusive)

  - ### flags

    int flags()
    A flags word, indicating the kind of range. Multiple flag bits may be set. Valid flags include:
    - `FLAG_STATEMENT`
    - `FLAG_BLOCK`
    - `FLAG_ASSIGNMENT`
    - `FLAG_FLOW_CONTROLLER`
    - `FLAG_FLOW_TARGET`
    - `FLAG_INVOKE`
    - `FLAG_CREATE`
    - `FLAG_BRANCH_TRUE`
    - `FLAG_BRANCH_FALSE`
    Returns:
      the flags
    See Also:
      - `CharacterRangeInfo.flags()`

  - ### of

    static CharacterRange of(Label startScope, Label endScope, int characterRangeStart, int characterRangeEnd, int flags)
    Returns a character range pseudo-instruction.
    Parameters:
      `startScope` - the start of the instruction range
      `endScope` - the end of the instruction range
      `characterRangeStart` - the encoded start of the character range region (inclusive)
      `characterRangeEnd` - the encoded end of the character range region (exclusive)
      `flags` - a flags word, indicating the kind of range
    Returns:
      a character range pseudo-instruction