Class Instrumenter


  • public final class Instrumenter
    extends java.lang.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.
    • Constructor Detail

      • Instrumenter

        public Instrumenter​(java.util.List<java.io.File> classpath)
                     throws java.io.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:
        java.io.IOException - if classes in the classpath could not be loaded up
        java.lang.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:
        java.lang.NullPointerException - if any argument is null
    • Method Detail

      • instrument

        public InstrumentationResult instrument​(byte[] input,
                                                InstrumentationSettings settings)
        Instruments a class.
        Parameters:
        input - class file contents
        settings - instrumentation settings
        Returns:
        instrumentation results
        Throws:
        java.lang.IllegalArgumentException - if the class could not be instrumented for some reason
        java.lang.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)