com.google.monitoring.runtime.instrumentation
Class VerifyingClassAdapter

java.lang.Object
  extended by org.objectweb.asm.ClassAdapter
      extended by com.google.monitoring.runtime.instrumentation.VerifyingClassAdapter
All Implemented Interfaces:
org.objectweb.asm.ClassVisitor

public class VerifyingClassAdapter
extends org.objectweb.asm.ClassAdapter

This is a class writer that gets used in place of the existing ClassWriter, and verifies properties of the class getting written. Currently, it only checks to see if the methods are of the correct length for Java methods (<64K).

Author:
jeremymanson@google.com (Jeremy Manson)

Nested Class Summary
static class VerifyingClassAdapter.State
          An enum which indicates whether the class in question is verified.
 
Constructor Summary
VerifyingClassAdapter(org.objectweb.asm.ClassWriter cw, byte[] original, String className)
           
 
Method Summary
 boolean isVerified()
          Gets the verification state of this class.
 byte[] toByteArray()
          Returns the byte array that contains the byte code for this class.
 void visitEnd()
          
 org.objectweb.asm.MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions)
           In addition, the returned MethodVisitor will throw an exception if the method is greater than 64K in length.
 
Methods inherited from class org.objectweb.asm.ClassAdapter
visit, visitAnnotation, visitAttribute, visitField, visitInnerClass, visitOuterClass, visitSource
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VerifyingClassAdapter

public VerifyingClassAdapter(org.objectweb.asm.ClassWriter cw,
                             byte[] original,
                             String className)
Parameters:
cw - A class writer that is wrapped by this class adapter
original - the original bytecode
className - the name of the class being examined.
Method Detail

visitMethod

public org.objectweb.asm.MethodVisitor visitMethod(int access,
                                                   String name,
                                                   String desc,
                                                   String signature,
                                                   String[] exceptions)
In addition, the returned MethodVisitor will throw an exception if the method is greater than 64K in length.

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

visitEnd

public void visitEnd()

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

isVerified

public boolean isVerified()
Gets the verification state of this class.

Returns:
true iff the class passed inspection.

toByteArray

public byte[] toByteArray()
Returns the byte array that contains the byte code for this class.

Returns:
a byte array.


Copyright © 2009-2011 Google, Inc.. All Rights Reserved.