Class Instrumenter

java.lang.Object
com.offbynull.coroutines.instrumenter.Instrumenter

public final class Instrumenter extends Object
Instruments methods in Java classes that are intended to be run as coroutines. Tested with Java 1.4 and Java 8, so hopefully thing should work with all versions of Java inbetween.
  • Field Details

  • Constructor Details

    • Instrumenter

      public Instrumenter(List<File> classpath) throws IOException
      Constructs a Instrumenter object from a filesystem classpath (folders and JARs).
      Parameters:
      classpath - classpath JARs and folders to use for instrumentation (this is needed by ASM to generate stack map frames).
      Throws:
      IOException - if classes in the classpath could not be loaded up
      NullPointerException - if any argument is null or contains null
    • Instrumenter

      public Instrumenter(ClassInformationRepository repo)
      Constructs a Instrumenter object.
      Parameters:
      repo - class information repository (this is needed by ASM to generate stack map frames).
      Throws:
      NullPointerException - if any argument is null
  • Method Details

    • instrument

      public InstrumentationResult instrument(byte[] input, InstrumentationSettings settings)
      Instruments a class.
      Parameters:
      input - class file contents
      settings - instrumentation settings
      Returns:
      instrumentation results
      Throws:
      IllegalArgumentException - if the class could not be instrumented for some reason
      NullPointerException - if any argument is null
    • verifyClassIntegrity

      private void verifyClassIntegrity(org.objectweb.asm.tree.ClassNode classNode)
    • reconstructStackMapFrames

      private org.objectweb.asm.tree.ClassNode reconstructStackMapFrames(org.objectweb.asm.tree.ClassNode classNode)