Class MethodIdMapping

java.lang.Object
fr.bl.drit.flow.agent.MethodIdMapping

public final class MethodIdMapping extends Object
Mapping of method keys (e.g. "com.example.MyClass#myMethod(Ljava/lang/String;)V") to numeric IDs used in the recorded traces. This is thread-safe and assigns new IDs on demand. The mapping can be initialized from an existing file to preserve or optimize method IDs across runs, and can be dumped to a file for future reuse.
  • Constructor Details

    • MethodIdMapping

      public MethodIdMapping()
      Initialize a blank mapping.
    • MethodIdMapping

      public MethodIdMapping(Path input) throws IOException
      Initialize mapping from an existing file, to preserve or optimize method IDs across runs.
      Parameters:
      input - Path to file containing lines of "key=id" generated by dump(Path) in a previous run.
      Throws:
      IOException - If an I/O error occurs when opening or reading the file.
  • Method Details

    • idFor

      public long idFor(String key)
      Get or compute a method ID for a given method.
      Parameters:
      key - Method signature
      Returns:
      Method ID
    • size

      public int size()
      Returns:
      Number of methods in the mapping
    • dump

      public void dump(Path output) throws IOException
      Dump the mapping to a file.
      Parameters:
      output - Path to output file
      Throws:
      IOException - If an I/O error occurs when opening the file.
    • dump

      public static void dump(Map<String,Long> mapping, Path output) throws IOException
      Dump the mapping to a file, for potential reuse in future runs. Format is lines of "key=id".
      Parameters:
      mapping - Map of signature -> ID
      output - Path to output file
      Throws:
      IOException - If an I/O error occurs when opening or writing the file.