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

Module java.base
Package java.lang.classfile.componentsPREVIEW

# Interface CodeLocalsShifter

All Superinterfaces:
  `ClassFileTransformPREVIEW<CodeTransformPREVIEW,CodeElementPREVIEW,CodeBuilderPREVIEW>`, `CodeTransformPREVIEW`

public sealed interface CodeLocalsShifter extends CodeTransformPREVIEW
`CodeLocalsShifter` is a preview API of the Java platform.
Programs can only use `CodeLocalsShifter` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
`CodeLocalsShifter`PREVIEW is a `CodeTransform`PREVIEW shifting locals to newly allocated positions to avoid conflicts during code injection. Locals pointing to the receiver or to method arguments slots are never shifted. All locals pointing beyond the method arguments are re-indexed in order of appearance.

Since:
  22

- ## Nested Class Summary

  ### Nested classes/interfaces declared in interface java.lang.classfile.ClassFileTransformPREVIEW

  `ClassFileTransform.ResolvedTransformPREVIEW<E extends ClassFileElementPREVIEW>`

- ## Field Summary

  ### Fields declared in interface java.lang.classfile.CodeTransformPREVIEW

  `ACCEPT_ALL`

- ## Method Summary

  Static Methods
  Modifier and Type
  Method
  Description
  `static CodeLocalsShifterPREVIEW`
  `of(AccessFlagsPREVIEW methodFlags, MethodTypeDesc methodDescriptor)`
  Creates a new instance of `CodeLocalsShifter`PREVIEW with fixed local slots calculated from provided method information.

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

  `accept, atEnd, atStart`

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

  `andThen, resolve`

- ## Method Details

  - ### of

    static CodeLocalsShifterPREVIEW of(AccessFlagsPREVIEW methodFlags, MethodTypeDesc methodDescriptor)
    Creates a new instance of `CodeLocalsShifter`PREVIEW with fixed local slots calculated from provided method information.
    Parameters:
      `methodFlags` - flags of the method to construct `CodeLocalsShifter`PREVIEW for
      `methodDescriptor` - descriptor of the method to construct `CodeLocalsShifter`PREVIEW for
    Returns:
      new instance of `CodeLocalsShifter`PREVIEW