de.uka.ipd.sdq.ByCounter.instrumentation
Class Instrumenter

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.instrumentation.Instrumenter

public final class Instrumenter
extends java.lang.Object

The instrumentor class is the central class to apply an instrumentation to a targeted class and receive the results.

Since:
0.1
Version:
1.2
Author:
Martin Krogmann, Michael Kuperberg

Constructor Summary
Instrumenter(byte[] classAsBytes, InstrumentationParameters parameters, InstrumentationState state)
          Creates an Instrumenter for the specified class.
Instrumenter(java.lang.String className, InstrumentationParameters params, InstrumentationState state)
          Creates an Instrumenter for the specified class.
 
Method Summary
 org.objectweb.asm.ClassAdapter getClassAdapter()
          Simple getter
 java.lang.String getClassCanonicalName()
          Simple getter
 java.lang.String getClassName()
          Gets the name of the instrumented class.
 org.objectweb.asm.ClassReader getClassReader()
          Simple getter
 org.objectweb.asm.ClassWriter getClassWriter()
          Simple getter
 InstrumentationParameters getInstrumentationParameters()
          Simple getter
 InstrumentationState getInstrumentationState()
           
 byte[] getInstrumentedBytes()
          Get the instrumented bytecode (before that, instrument if needed)
 long getInstrumentedBytesize()
           
 long[] getMeasurements()
          Return the time measurements and bytesizes obtained during characterisation.
 long getTimestampAfterReaderAccept_3()
           
 long getTimestampBeforeASMSetup_1()
           
 long getTimestampBeforeReaderAccept_2()
           
 long getTimestampBeforeReaderInitialisation_0()
           
 long getTimestampInstrumenterInitialisation()
           
 byte[] getUninstrumentedBytes()
           
 long getUninstrumentedBytesize()
          if uninstrumentedBytes field is not null, return it size.
 boolean instrument()
          Instrument bytecode using ASM.
 boolean isInstrumentationFinished()
           
 void registerCharacterisationHook(ICharacterisationHook hook)
          Registers a ICharacterisationHook.
 void setInstrumentationParameters(InstrumentationParameters instrumentationParameters)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Instrumenter

public Instrumenter(byte[] classAsBytes,
                    InstrumentationParameters parameters,
                    InstrumentationState state)
Creates an Instrumenter for the specified class.

Parameters:
classAsBytes - The class that holds the methods that are to be instrumented as byte array.
parameters - InstrumentationParameters instance that specifies how and what to instrument.

Instrumenter

public Instrumenter(java.lang.String className,
                    InstrumentationParameters params,
                    InstrumentationState state)
             throws java.lang.ClassNotFoundException
Creates an Instrumenter for the specified class.

Parameters:
className - The name of the class holding the methods that shall be instrumented. Needs to be fully qualified as this is used to find the correct class.
params - InstrumentationParameters instance that specifies how and what to instrument.
state - InstrumentationState for this Instrumenter.
Throws:
java.lang.ClassNotFoundException - If the specified name cannot be resolved, this exception is thrown. Check your className if you get this exception.
Method Detail

getClassAdapter

public org.objectweb.asm.ClassAdapter getClassAdapter()
Simple getter

Returns:
class adapter used by this instrumenter

getClassCanonicalName

public java.lang.String getClassCanonicalName()
Simple getter

Returns:
the canonical name of the class for which this instrumenter is responsible

getClassName

public java.lang.String getClassName()
Gets the name of the instrumented class.

Returns:
The internal name of the class that is instrumented. The internal name of a class is its fully qualified name (as returned by Class.getName(), where '.' are replaced by '/'.)

getClassReader

public org.objectweb.asm.ClassReader getClassReader()
Simple getter

Returns:
the class reader instance

getClassWriter

public org.objectweb.asm.ClassWriter getClassWriter()
Simple getter

Returns:
the class writer instance

getInstrumentationParameters

public InstrumentationParameters getInstrumentationParameters()
Simple getter

Returns:
the instrumentationParameters

getInstrumentationState

public InstrumentationState getInstrumentationState()
Returns:
The InstrumentationState.

getInstrumentedBytes

public byte[] getInstrumentedBytes()
Get the instrumented bytecode (before that, instrument if needed)

Returns:
A byte array containing the modified bytecode.

getInstrumentedBytesize

public long getInstrumentedBytesize()
Returns:
If already instrumented, return the bytesize of the instrumentation result. Otherwise, return -1.

getMeasurements

public long[] getMeasurements()
Return the time measurements and bytesizes obtained during characterisation.

Returns:
time measurements and bytesizes in an array - see source code for details.

getTimestampAfterReaderAccept_3

public long getTimestampAfterReaderAccept_3()

getTimestampBeforeASMSetup_1

public long getTimestampBeforeASMSetup_1()

getTimestampBeforeReaderAccept_2

public long getTimestampBeforeReaderAccept_2()

getTimestampBeforeReaderInitialisation_0

public long getTimestampBeforeReaderInitialisation_0()

getTimestampInstrumenterInitialisation

public long getTimestampInstrumenterInitialisation()

getUninstrumentedBytes

public byte[] getUninstrumentedBytes()

getUninstrumentedBytesize

public long getUninstrumentedBytesize()
if uninstrumentedBytes field is not null, return it size. Otherwise, return -1.

Returns:
see method description above.

instrument

public boolean instrument()
Instrument bytecode using ASM. To get the results, call getInstrumentedBytes().

Returns:
True, when the instrumentation of all specified methods was successful, false otherwise.

isInstrumentationFinished

public boolean isInstrumentationFinished()
Returns:
When true, the instrumentation process has finished.

registerCharacterisationHook

public void registerCharacterisationHook(ICharacterisationHook hook)
Registers a ICharacterisationHook.

Parameters:
hook -
See Also:
ICharacterisationHook

setInstrumentationParameters

public void setInstrumentationParameters(InstrumentationParameters instrumentationParameters)
Parameters:
instrumentationParameters - the instrumentationParameters to set