Class Instrumenter
- java.lang.Object
-
- com.offbynull.coroutines.instrumenter.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.
-
-
Field Summary
Fields Modifier and Type Field Description private ClassInformationRepository
classRepo
-
Constructor Summary
Constructors Constructor Description Instrumenter(ClassInformationRepository repo)
Constructs aInstrumenter
object.Instrumenter(java.util.List<java.io.File> classpath)
Constructs aInstrumenter
object from a filesystem classpath (folders and JARs).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description InstrumentationResult
instrument(byte[] input, InstrumentationSettings settings)
Instruments a class.private org.objectweb.asm.tree.ClassNode
reconstructStackMapFrames(org.objectweb.asm.tree.ClassNode classNode)
private void
verifyClassIntegrity(org.objectweb.asm.tree.ClassNode classNode)
-
-
-
Field Detail
-
classRepo
private ClassInformationRepository classRepo
-
-
Constructor Detail
-
Instrumenter
public Instrumenter(java.util.List<java.io.File> classpath) throws java.io.IOException
Constructs aInstrumenter
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 upjava.lang.NullPointerException
- if any argument isnull
or containsnull
-
Instrumenter
public Instrumenter(ClassInformationRepository repo)
Constructs aInstrumenter
object.- Parameters:
repo
- class information repository (this is needed by ASM to generate stack map frames).- Throws:
java.lang.NullPointerException
- if any argument isnull
-
-
Method Detail
-
instrument
public InstrumentationResult instrument(byte[] input, InstrumentationSettings settings)
Instruments a class.- Parameters:
input
- class file contentssettings
- instrumentation settings- Returns:
- instrumentation results
- Throws:
java.lang.IllegalArgumentException
- if the class could not be instrumented for some reasonjava.lang.NullPointerException
- if any argument isnull
-
verifyClassIntegrity
private void verifyClassIntegrity(org.objectweb.asm.tree.ClassNode classNode)
-
reconstructStackMapFrames
private org.objectweb.asm.tree.ClassNode reconstructStackMapFrames(org.objectweb.asm.tree.ClassNode classNode)
-
-