Interface BytecodeBackend

All Known Implementing Classes:
AsmBytecodeBackend

public interface BytecodeBackend
Engine of class files: the ClassFile API of JDK 24+ or ASM. Generated copiers and copy constructors do not depend on it: they describe fields and methods, and the code of methods is emitted by CodeEmitter.

Code with branches needs stack map frames, which the engine computes; the code of methods added to a class must not branch, so the frames need no types of other classes.

  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    addMembers(byte[] bytes, List<FieldSpec> fields, List<MethodSpec> methods)
    Adds fields and methods to the class file, the rest of it stays as is.
    boolean
    canRead(byte[] bytes)
    Tells whether the engine reads the class file: a newer version than the engine knows cannot be read.
    read(byte[] bytes)
    Reads the structure of the class file.
    byte[]
    write(int version, String name, String superName, List<FieldSpec> fields, List<MethodSpec> methods)
    Writes a final synthetic class.
  • Method Details

    • write

      byte[] write(int version, String name, String superName, List<FieldSpec> fields, List<MethodSpec> methods)
      Writes a final synthetic class.
      Parameters:
      version - class file version
      name - internal name of the class
      superName - internal name of the super class
      fields - fields
      methods - methods
      Returns:
      class file
    • canRead

      boolean canRead(byte[] bytes)
      Tells whether the engine reads the class file: a newer version than the engine knows cannot be read.
      Parameters:
      bytes - class file
      Returns:
      true if read(byte[]) and addMembers(byte[], List, List) accept it
    • read

      ClassStructure read(byte[] bytes)
      Reads the structure of the class file.
      Parameters:
      bytes - class file
      Returns:
      structure
    • addMembers

      byte[] addMembers(byte[] bytes, List<FieldSpec> fields, List<MethodSpec> methods)
      Adds fields and methods to the class file, the rest of it stays as is.
      Parameters:
      bytes - class file
      fields - fields to add
      methods - methods to add, their code does not branch
      Returns:
      new class file