Interface CodeRelabeler

All Superinterfaces:
ClassfileTransform<CodeTransform,CodeElement,CodeBuilder>, CodeTransform
All Known Implementing Classes:
CodeRelabeler.CodeRelabelerImpl

public sealed interface CodeRelabeler extends CodeTransform permits CodeRelabeler.CodeRelabelerImpl
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.

  • Method Details

    • of

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

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

      static CodeRelabeler of(BiFunction<Label,CodeBuilder,Label> mapFunction)
      Creates new instance of CodeRelabeler using provided BiFunction to re-label the code.
      Parameters:
      mapFunction -
      Returns:
    • relabel

      Label relabel(Label label, CodeBuilder codeBuilder)
      Access method to internal re-labeling function.
      Parameters:
      label - source label
      codeBuilder - builder to create new labels
      Returns:
      target label