Module java.base
Package java.lang.classfile.instructionPREVIEW

# Interface ReturnInstruction

All Superinterfaces:
  `ClassFileElementPREVIEW`, `CodeElementPREVIEW`, `InstructionPREVIEW`

public sealed interface ReturnInstruction extends InstructionPREVIEW
`ReturnInstruction` is a preview API of the Java platform.
Programs can only use `ReturnInstruction` when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Models a return-from-method instruction in the `code` array of a `Code` attribute. Corresponding opcodes will have a `kind` of `Opcode.Kind.RETURN`PREVIEW. Delivered as a `CodeElement`PREVIEW when traversing the elements of a `CodeModel`PREVIEW.

Since:
  22

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ReturnInstructionPREVIEW`
  `of(OpcodePREVIEW op)`
  Returns a return instruction.
  `static ReturnInstructionPREVIEW`
  `of(TypeKindPREVIEW typeKind)`
  Returns a return instruction.
  `TypeKindPREVIEW`
  `typeKind()`
  Returns the type of the return instruction.

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

  `opcode, sizeInBytes`

- ## Method Details

  - ### typeKind

    TypeKindPREVIEW typeKind()
    Returns the type of the return instruction.
    Returns:
      the type of the return instruction

  - ### of

    static ReturnInstructionPREVIEW of(TypeKindPREVIEW typeKind)
    Returns a return instruction.
    Parameters:
      `typeKind` - the type of the return instruction
    Returns:
      a return instruction

  - ### of

    static ReturnInstructionPREVIEW of(OpcodePREVIEW op)
    Returns a return instruction.
    Parameters:
      `op` - the opcode for the specific type of return instruction, which must be of kind `Opcode.Kind.RETURN`PREVIEW
    Returns:
      a return instruction