Class JimpleBodySerializer

java.lang.Object
sootup.core.util.JimpleBodySerializer

public class JimpleBodySerializer extends Object
Serializes a Body or ControlFlowGraph to Java source code that, when compiled and executed, recreates the same in-memory representation using the SootUp API.

Usage: copy the returned snippet into a test method, supply the identifierFactory variable and an appropriate MethodSignature, then call body.build().

Why: You want to test different scenarios and have existing similar bytecode? Transform it to Jimple and serialize the ControlFlowGraph to Java sourcecode that generates the Jimple Objects directly Use it as a base that you can modify easily/fast for writing test input.

  • Constructor Details

    • JimpleBodySerializer

      public JimpleBodySerializer()
  • Method Details

    • serialize

      public static String serialize(Body body)
      Serialize a full Body (includes the Body.builder(...).build() call).
    • serialize

      public static String serialize(ControlFlowGraph<?> cfg, Set<Local> locals)
      Serialize a CFG and its locals. The generated snippet ends with a fully configured Body.builder(graph) call — supply a MethodSignature where indicated.