org.jacoco.core.instr
Class Instrumenter

java.lang.Object
  extended by org.jacoco.core.instr.Instrumenter

public class Instrumenter
extends Object

Several APIs to instrument Java class definitions for coverage tracing.

Version:
0.4.1.20101007204400
Author:
Marc R. Hoffmann

Constructor Summary
Instrumenter(IRuntime runtime)
          Creates a new instance based on the given runtime.
 
Method Summary
 ClassVisitor createInstrumentingVisitor(long classid, ClassVisitor cv)
          Creates a ASM adapter for a class with the given id.
 byte[] instrument(byte[] buffer)
          Creates a instrumented version of the given class if possible.
 byte[] instrument(ClassReader reader)
          Creates a instrumented version of the given class if possible.
 byte[] instrument(InputStream input)
          Creates a instrumented version of the given class if possible.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Instrumenter

public Instrumenter(IRuntime runtime)
Creates a new instance based on the given runtime.

Parameters:
runtime - runtime used by the instrumented classes
Method Detail

createInstrumentingVisitor

public ClassVisitor createInstrumentingVisitor(long classid,
                                               ClassVisitor cv)
Creates a ASM adapter for a class with the given id.

Parameters:
classid - id of the class calculated with CRC64
cv - next class visitor in the chain
Returns:
new visitor to write class definition to

instrument

public byte[] instrument(ClassReader reader)
Creates a instrumented version of the given class if possible.

Parameters:
reader - definition of the class as ASM reader
Returns:
instrumented definition or null

instrument

public byte[] instrument(byte[] buffer)
Creates a instrumented version of the given class if possible.

Parameters:
buffer - definition of the class
Returns:
instrumented definition or null

instrument

public byte[] instrument(InputStream input)
                  throws IOException
Creates a instrumented version of the given class if possible.

Parameters:
input - stream to read class definition from
Returns:
instrumented definition or null
Throws:
IOException - if reading data from the stream fails