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

java.lang.Object
  extended by org.objectweb.asm.ClassAdapter
      extended by de.uka.ipd.sdq.ByCounter.instrumentation.MethodCountClassAdapter
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor

public final class MethodCountClassAdapter
extends org.objectweb.asm.ClassAdapter

This is the visitor for the class declaration. It watches each method declaration and selects the methods which have to be instrumented as specified in the instrumentation parameters. For those methods, the MethodCountMethodAdapter is activated.

Since:
0.1
Version:
1.2
Author:
Martin Krogmann, Michael Kuperberg
See Also:
MethodCountMethodAdapter

Field Summary
static java.lang.String DIRECT_LOG_WRITE_SIGNATURE
           
static java.lang.String METHOD_RENAMING_POSTFIX
          This is the postfix to the name of instrumented methods for the versions,
 
Constructor Summary
MethodCountClassAdapter(org.objectweb.asm.ClassVisitor visitor, InstrumentationParameters parameters, InstrumentationState state)
          Create a new MethodCountAdapter.
 
Method Summary
static java.lang.String constructResultLogFileName(java.lang.String resultLogFileNameTemplate, java.lang.String qualifyingMethodName, long timestamp)
          Constructs the filename for the result log by replacing the template strings.
 void registerCharacterisationHook(ICharacterisationHook hook)
          Register a ICharacterisationHook.
 void visit(int version, int access, java.lang.String name, java.lang.String signature, java.lang.String supername, java.lang.String[] interfaces)
          Visits the header of the class and grabs the classname.
 void visitEnd()
          Overridden to insert a result log writing method.
 org.objectweb.asm.MethodVisitor visitMethod(int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions)
          This is called when a method declaration happens in the class.
 
Methods inherited from class org.objectweb.asm.ClassAdapter
visitAnnotation, visitAttribute, visitField, visitInnerClass, visitOuterClass, visitSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHOD_RENAMING_POSTFIX

public static final java.lang.String METHOD_RENAMING_POSTFIX
This is the postfix to the name of instrumented methods for the versions,


DIRECT_LOG_WRITE_SIGNATURE

public static final java.lang.String DIRECT_LOG_WRITE_SIGNATURE
See Also:
Constant Field Values
Constructor Detail

MethodCountClassAdapter

public MethodCountClassAdapter(org.objectweb.asm.ClassVisitor visitor,
                               InstrumentationParameters parameters,
                               InstrumentationState state)
Create a new MethodCountAdapter.

Parameters:
visitor - The preceding visitor in the chain.
parameters - InstrumentationParameters
state - InstrumentationState
Method Detail

constructResultLogFileName

public static java.lang.String constructResultLogFileName(java.lang.String resultLogFileNameTemplate,
                                                          java.lang.String qualifyingMethodName,
                                                          long timestamp)
Constructs the filename for the result log by replacing the template strings.

Parameters:
resultLogFileNameTemplate - A prefix.
qualifyingMethodName - The qualifying name of the calling method.
timestamp - A timestamp of the execution time.
Returns:
The resulting file name string.
See Also:
InstrumentationParameters.enableResultLogWriter(String)

registerCharacterisationHook

public void registerCharacterisationHook(ICharacterisationHook hook)
Register a ICharacterisationHook.

Parameters:
hook -
See Also:
ICharacterisationHook

visit

public void visit(int version,
                  int access,
                  java.lang.String name,
                  java.lang.String signature,
                  java.lang.String supername,
                  java.lang.String[] interfaces)
Visits the header of the class and grabs the classname. This is being called from other class visitors in the chain for classes that get passed to the Instrumenter. The classname attribute is important as it serves for describing the output in logs or files in order to associate counts to the correct classes/methods.

Specified by:
visit in interface org.objectweb.asm.ClassVisitor
Overrides:
visit in class org.objectweb.asm.ClassAdapter
See Also:
Instrumenter

visitEnd

public void visitEnd()
Overridden to insert a result log writing method.

Specified by:
visitEnd in interface org.objectweb.asm.ClassVisitor
Overrides:
visitEnd in class org.objectweb.asm.ClassAdapter
See Also:
ClassAdapter.visitEnd()

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   java.lang.String name,
                                                   java.lang.String desc,
                                                   java.lang.String signature,
                                                   java.lang.String[] exceptions)
This is called when a method declaration happens in the class.

Specified by:
visitMethod in interface org.objectweb.asm.ClassVisitor
Overrides:
visitMethod in class org.objectweb.asm.ClassAdapter