com.ikokoon.serenity.instrumentation.complexity
Class ComplexityMethodAdapter

java.lang.Object
  extended by org.objectweb.asm.MethodAdapter
      extended by com.ikokoon.serenity.instrumentation.complexity.ComplexityMethodAdapter
All Implemented Interfaces:
org.objectweb.asm.MethodVisitor

public class ComplexityMethodAdapter
extends org.objectweb.asm.MethodAdapter

TODO - add the interesting methods to the collection of the complexity. Do we need to add try catch? And what about multiple catch? One for each potential exception thrown? No? This class just visits the byte code in the classes and collects the complexity metrics for the class. Complexity is calculated by adding one every time there is a jump instruction.

Since:
12.07.09
Version:
01.00
Author:
Michael Couck

Field Summary
 
Fields inherited from class org.objectweb.asm.MethodAdapter
mv
 
Constructor Summary
ComplexityMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor, java.lang.Integer access, java.lang.String className, java.lang.String methodName, java.lang.String methodDescription)
          The constructor initialises a ComplexityMethodAdapter that takes all the interesting items for the method that is to be enhanced including the parent method visitor.
 
Method Summary
 void visitEnd()
          
 void visitInsn(int opcode)
          
 void visitJumpInsn(int opcode, org.objectweb.asm.Label paramLabel)
          
 void visitLineNumber(int lineNumber, org.objectweb.asm.Label label)
          
 void visitLookupSwitchInsn(org.objectweb.asm.Label dflt, int[] keys, org.objectweb.asm.Label[] labels)
          
 void visitTableSwitchInsn(int min, int max, org.objectweb.asm.Label dflt, org.objectweb.asm.Label[] labels)
          
 void visitTryCatchBlock(org.objectweb.asm.Label start, org.objectweb.asm.Label end, org.objectweb.asm.Label handler, java.lang.String type)
          
 
Methods inherited from class org.objectweb.asm.MethodAdapter
visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitFieldInsn, visitFrame, visitIincInsn, visitIntInsn, visitLabel, visitLdcInsn, visitLocalVariable, visitMaxs, visitMethodInsn, visitMultiANewArrayInsn, visitParameterAnnotation, visitTypeInsn, visitVarInsn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexityMethodAdapter

public ComplexityMethodAdapter(org.objectweb.asm.MethodVisitor methodVisitor,
                               java.lang.Integer access,
                               java.lang.String className,
                               java.lang.String methodName,
                               java.lang.String methodDescription)
The constructor initialises a ComplexityMethodAdapter that takes all the interesting items for the method that is to be enhanced including the parent method visitor.

Parameters:
methodVisitor - the method visitor of the parent
className - the name of the class the method belongs to
methodName - the name of the method that will be collected for complexity
methodDescription - the description of the method, i.e. the byte code signature
Method Detail

visitLineNumber

public void visitLineNumber(int lineNumber,
                            org.objectweb.asm.Label label)

Specified by:
visitLineNumber in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLineNumber in class org.objectweb.asm.MethodAdapter

visitJumpInsn

public void visitJumpInsn(int opcode,
                          org.objectweb.asm.Label paramLabel)

Specified by:
visitJumpInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitJumpInsn in class org.objectweb.asm.MethodAdapter

visitEnd

public void visitEnd()

Specified by:
visitEnd in interface org.objectweb.asm.MethodVisitor
Overrides:
visitEnd in class org.objectweb.asm.MethodAdapter

visitTryCatchBlock

public void visitTryCatchBlock(org.objectweb.asm.Label start,
                               org.objectweb.asm.Label end,
                               org.objectweb.asm.Label handler,
                               java.lang.String type)

Specified by:
visitTryCatchBlock in interface org.objectweb.asm.MethodVisitor
Overrides:
visitTryCatchBlock in class org.objectweb.asm.MethodAdapter

visitLookupSwitchInsn

public void visitLookupSwitchInsn(org.objectweb.asm.Label dflt,
                                  int[] keys,
                                  org.objectweb.asm.Label[] labels)

Specified by:
visitLookupSwitchInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitLookupSwitchInsn in class org.objectweb.asm.MethodAdapter

visitTableSwitchInsn

public void visitTableSwitchInsn(int min,
                                 int max,
                                 org.objectweb.asm.Label dflt,
                                 org.objectweb.asm.Label[] labels)

Specified by:
visitTableSwitchInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitTableSwitchInsn in class org.objectweb.asm.MethodAdapter

visitInsn

public void visitInsn(int opcode)

Specified by:
visitInsn in interface org.objectweb.asm.MethodVisitor
Overrides:
visitInsn in class org.objectweb.asm.MethodAdapter


Copyright © 2010. All Rights Reserved.