Interface CodeRelabeler

All Superinterfaces:
ClassFileTransform<CodeTransform, CodeElement, CodeBuilder>, CodeTransform

public sealed interface CodeRelabeler extends CodeTransform
A code relabeler is a CodeTransform replacing all occurrences of Label in the transformed code with new instances. All LabelTarget instructions are adjusted accordingly. Relabeled code graph is identical to the original.

Primary purpose of CodeRelabeler is for repeated injections of the same code blocks. Repeated injection of the same code block must be relabeled, so each instance of Label is bound in the target bytecode exactly once.

Since:
24
  • Method Details

    • of

      static CodeRelabeler of()
      Creates a new instance of CodeRelabeler.
      Returns:
      a new instance of CodeRelabeler
    • of

      static CodeRelabeler of(Map<Label,Label> map)
      Creates a new instance of CodeRelabeler storing the label mapping into the provided map.
      Parameters:
      map - label map actively used for relabeling
      Returns:
      a new instance of CodeRelabeler
    • of

      static CodeRelabeler of(BiFunction<Label, CodeBuilder, Label> mapFunction)
      Creates a new instance of CodeRelabeler using provided BiFunction to re-label the code.
      Parameters:
      mapFunction - function for remapping labels in the source code model
      Returns:
      a new instance of CodeRelabeler