org.multiverse.instrumentation.asm
Class AsmUtils

java.lang.Object
  extended by org.multiverse.instrumentation.asm.AsmUtils
All Implemented Interfaces:
org.objectweb.asm.Opcodes

public final class AsmUtils
extends java.lang.Object
implements org.objectweb.asm.Opcodes


Field Summary
 
Fields inherited from interface org.objectweb.asm.Opcodes
AALOAD, AASTORE, ACC_ABSTRACT, ACC_ANNOTATION, ACC_BRIDGE, ACC_DEPRECATED, ACC_ENUM, ACC_FINAL, ACC_INTERFACE, ACC_NATIVE, ACC_PRIVATE, ACC_PROTECTED, ACC_PUBLIC, ACC_STATIC, ACC_STRICT, ACC_SUPER, ACC_SYNCHRONIZED, ACC_SYNTHETIC, ACC_TRANSIENT, ACC_VARARGS, ACC_VOLATILE, ACONST_NULL, ALOAD, ANEWARRAY, ARETURN, ARRAYLENGTH, ASTORE, ATHROW, BALOAD, BASTORE, BIPUSH, CALOAD, CASTORE, CHECKCAST, D2F, D2I, D2L, DADD, DALOAD, DASTORE, DCMPG, DCMPL, DCONST_0, DCONST_1, DDIV, DLOAD, DMUL, DNEG, DOUBLE, DREM, DRETURN, DSTORE, DSUB, DUP, DUP_X1, DUP_X2, DUP2, DUP2_X1, DUP2_X2, F_APPEND, F_CHOP, F_FULL, F_NEW, F_SAME, F_SAME1, F2D, F2I, F2L, FADD, FALOAD, FASTORE, FCMPG, FCMPL, FCONST_0, FCONST_1, FCONST_2, FDIV, FLOAD, FLOAT, FMUL, FNEG, FREM, FRETURN, FSTORE, FSUB, GETFIELD, GETSTATIC, GOTO, I2B, I2C, I2D, I2F, I2L, I2S, IADD, IALOAD, IAND, IASTORE, ICONST_0, ICONST_1, ICONST_2, ICONST_3, ICONST_4, ICONST_5, ICONST_M1, IDIV, IF_ACMPEQ, IF_ACMPNE, IF_ICMPEQ, IF_ICMPGE, IF_ICMPGT, IF_ICMPLE, IF_ICMPLT, IF_ICMPNE, IFEQ, IFGE, IFGT, IFLE, IFLT, IFNE, IFNONNULL, IFNULL, IINC, ILOAD, IMUL, INEG, INSTANCEOF, INTEGER, INVOKEDYNAMIC, INVOKEDYNAMIC_OWNER, INVOKEINTERFACE, INVOKESPECIAL, INVOKESTATIC, INVOKEVIRTUAL, IOR, IREM, IRETURN, ISHL, ISHR, ISTORE, ISUB, IUSHR, IXOR, JSR, L2D, L2F, L2I, LADD, LALOAD, LAND, LASTORE, LCMP, LCONST_0, LCONST_1, LDC, LDIV, LLOAD, LMUL, LNEG, LONG, LOOKUPSWITCH, LOR, LREM, LRETURN, LSHL, LSHR, LSTORE, LSUB, LUSHR, LXOR, MONITORENTER, MONITOREXIT, MULTIANEWARRAY, NEW, NEWARRAY, NOP, NULL, POP, POP2, PUTFIELD, PUTSTATIC, RET, RETURN, SALOAD, SASTORE, SIPUSH, SWAP, T_BOOLEAN, T_BYTE, T_CHAR, T_DOUBLE, T_FLOAT, T_INT, T_LONG, T_SHORT, TABLESWITCH, TOP, UNINITIALIZED_THIS, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7
 
Method Summary
static java.util.List<org.objectweb.asm.tree.LocalVariableNode> cloneLocalVariableTable(org.objectweb.asm.tree.MethodNode originalMethod, CloneMap cloneMap)
           
static org.objectweb.asm.tree.MethodNode cloneMethodWithoutInstructions(org.objectweb.asm.tree.MethodNode originalMethod, CloneMap cloneMap)
           
static java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> cloneTryCatchBlockNodes(java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> originalBlocks, CloneMap cloneMap)
           
static java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> cloneTryCatchBlocks(org.objectweb.asm.tree.MethodNode originalMethod, CloneMap cloneMap)
           
static java.util.List cloneVariableTable(org.objectweb.asm.tree.MethodNode methodNode, CloneMap cloneMap)
           
static java.lang.String createMethodDescriptorWithRightIntroducedVariable(java.lang.String methodDesc, java.lang.String extraArgType)
           
static DebugInfo findDebugInfo(org.objectweb.asm.tree.MethodNode method)
           
static int firstIndexAfterSuper(org.objectweb.asm.tree.MethodNode methodNode, java.lang.String superClass)
           
static int firstIndexAfterSuper(java.lang.String methodName, org.objectweb.asm.tree.InsnList instructions, java.lang.String superClass)
           
static java.lang.Object getAnnotationValue(org.objectweb.asm.tree.AnnotationNode annotationNode, java.lang.String valueName)
           
static java.lang.String[] getExceptions(org.objectweb.asm.tree.MethodNode originalMethod)
           
static java.lang.reflect.Field getField(java.lang.Class clazz, java.lang.String fieldName)
           
static int getInvokeOpcode(org.objectweb.asm.tree.MethodNode methodNode)
           
static java.lang.String getTmpDir()
           
static org.objectweb.asm.tree.AnnotationNode getVisibleAnnotation(org.objectweb.asm.tree.MemberNode memberNode, java.lang.Class annotationClass)
           
static boolean hasVisibleAnnotation(org.objectweb.asm.tree.MemberNode memberNode, java.lang.Class annotationClass)
          Checks if a ClassNode has the specified visible annotation.
static java.lang.String internalToDesc(java.lang.String internalForm)
           
static boolean isAbstract(int access)
           
static boolean isAbstract(org.objectweb.asm.tree.MethodNode methodNode)
           
static boolean isCategory2(java.lang.String valueDesc)
           
static boolean isFinal(org.objectweb.asm.tree.FieldNode fieldNode)
           
static boolean isFinal(int access)
           
static boolean isInterface(org.objectweb.asm.tree.ClassNode classNode)
           
static boolean isNative(int access)
           
static boolean isNative(org.objectweb.asm.tree.MethodNode methodNode)
           
static boolean isPrivate(int access)
           
static boolean isPrivate(org.objectweb.asm.tree.MethodNode methodNode)
           
static boolean isProtected(int access)
           
static boolean isPublic(int access)
           
static boolean isStatic(org.objectweb.asm.tree.FieldNode fieldNode)
           
static boolean isStatic(int access)
           
static boolean isStatic(org.objectweb.asm.tree.MethodNode methodNode)
           
static boolean isSynthetic(int access)
           
static byte[] loadAsBytecode(java.io.File file)
           
static org.objectweb.asm.tree.ClassNode loadAsClassNode(byte[] bytecode)
           
static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.lang.Class clazz)
          Loads a Class as ClassNode.
static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.lang.ClassLoader loader, java.lang.String classInternalName)
          Loads a Class as ClassNode.
static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.io.File file)
          Loads a Class as ClassNode.
static void printClass(java.lang.Class clazz)
           
static void printClassOfTopItem(org.objectweb.asm.tree.InsnList instructions)
           
static org.objectweb.asm.tree.MethodNode remap(org.objectweb.asm.tree.MethodNode originalMethod, org.objectweb.asm.commons.Remapper remapper)
           
static int sizeOfFormalParameters(java.lang.String desc)
           
static byte[] toBytecode(org.objectweb.asm.tree.ClassNode classNode)
           
static java.lang.String toString(org.objectweb.asm.tree.AbstractInsnNode insnNode)
           
static int upgradeToProtected(int access)
           
static int upgradeToPublic(int access)
           
static void writeToFile(java.io.File file, byte[] bytecode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

cloneMethodWithoutInstructions

public static org.objectweb.asm.tree.MethodNode cloneMethodWithoutInstructions(org.objectweb.asm.tree.MethodNode originalMethod,
                                                                               CloneMap cloneMap)

cloneLocalVariableTable

public static java.util.List<org.objectweb.asm.tree.LocalVariableNode> cloneLocalVariableTable(org.objectweb.asm.tree.MethodNode originalMethod,
                                                                                               CloneMap cloneMap)

cloneTryCatchBlocks

public static java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> cloneTryCatchBlocks(org.objectweb.asm.tree.MethodNode originalMethod,
                                                                                           CloneMap cloneMap)

printClassOfTopItem

public static void printClassOfTopItem(org.objectweb.asm.tree.InsnList instructions)

printClass

public static void printClass(java.lang.Class clazz)

findDebugInfo

public static DebugInfo findDebugInfo(org.objectweb.asm.tree.MethodNode method)

getInvokeOpcode

public static int getInvokeOpcode(org.objectweb.asm.tree.MethodNode methodNode)

cloneTryCatchBlockNodes

public static java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> cloneTryCatchBlockNodes(java.util.List<org.objectweb.asm.tree.TryCatchBlockNode> originalBlocks,
                                                                                               CloneMap cloneMap)

cloneVariableTable

public static java.util.List cloneVariableTable(org.objectweb.asm.tree.MethodNode methodNode,
                                                CloneMap cloneMap)

firstIndexAfterSuper

public static int firstIndexAfterSuper(java.lang.String methodName,
                                       org.objectweb.asm.tree.InsnList instructions,
                                       java.lang.String superClass)

firstIndexAfterSuper

public static int firstIndexAfterSuper(org.objectweb.asm.tree.MethodNode methodNode,
                                       java.lang.String superClass)

toString

public static java.lang.String toString(org.objectweb.asm.tree.AbstractInsnNode insnNode)

sizeOfFormalParameters

public static int sizeOfFormalParameters(java.lang.String desc)

isCategory2

public static boolean isCategory2(java.lang.String valueDesc)

upgradeToPublic

public static int upgradeToPublic(int access)

upgradeToProtected

public static int upgradeToProtected(int access)

createMethodDescriptorWithRightIntroducedVariable

public static java.lang.String createMethodDescriptorWithRightIntroducedVariable(java.lang.String methodDesc,
                                                                                 java.lang.String extraArgType)
Parameters:
methodDesc - the original method descriptor
extraArgType - internal name of extra argument to add to the right
Returns:
the new method descripion

remap

public static org.objectweb.asm.tree.MethodNode remap(org.objectweb.asm.tree.MethodNode originalMethod,
                                                      org.objectweb.asm.commons.Remapper remapper)

getExceptions

public static java.lang.String[] getExceptions(org.objectweb.asm.tree.MethodNode originalMethod)

loadAsClassNode

public static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.lang.Class clazz)
Loads a Class as ClassNode. The ClassLoader of the Class is used to retrieve a resource stream.

Parameters:
clazz - the Class to load as ClassNode.
Returns:
the loaded ClassNode.

loadAsClassNode

public static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.lang.ClassLoader loader,
                                                               java.lang.String classInternalName)
Loads a Class as ClassNode.

Parameters:
loader - the ClassLoader to getClassMetadata the resource stream of.
classInternalName - the internal name of the Class to load.
Returns:
the loaded ClassNode.

loadAsClassNode

public static org.objectweb.asm.tree.ClassNode loadAsClassNode(java.io.File file)
Loads a Class as ClassNode.

todo: code of this method is very nasty with closing streams.

Returns:
the loaded ClassNode.

loadAsBytecode

public static byte[] loadAsBytecode(java.io.File file)

hasVisibleAnnotation

public static boolean hasVisibleAnnotation(org.objectweb.asm.tree.MemberNode memberNode,
                                           java.lang.Class annotationClass)
Checks if a ClassNode has the specified visible annotation.

Parameters:
memberNode - the ClassNode to check
annotationClass - the Annotation class that is checked for.
Returns:
true if classNode has the specified annotation, false otherwise.

getVisibleAnnotation

public static org.objectweb.asm.tree.AnnotationNode getVisibleAnnotation(org.objectweb.asm.tree.MemberNode memberNode,
                                                                         java.lang.Class annotationClass)

getAnnotationValue

public static java.lang.Object getAnnotationValue(org.objectweb.asm.tree.AnnotationNode annotationNode,
                                                  java.lang.String valueName)

internalToDesc

public static java.lang.String internalToDesc(java.lang.String internalForm)

getField

public static java.lang.reflect.Field getField(java.lang.Class clazz,
                                               java.lang.String fieldName)

isAbstract

public static boolean isAbstract(org.objectweb.asm.tree.MethodNode methodNode)

isInterface

public static boolean isInterface(org.objectweb.asm.tree.ClassNode classNode)

isNative

public static boolean isNative(org.objectweb.asm.tree.MethodNode methodNode)

isFinal

public static boolean isFinal(org.objectweb.asm.tree.FieldNode fieldNode)

isStatic

public static boolean isStatic(org.objectweb.asm.tree.FieldNode fieldNode)

isStatic

public static boolean isStatic(org.objectweb.asm.tree.MethodNode methodNode)

isPrivate

public static boolean isPrivate(org.objectweb.asm.tree.MethodNode methodNode)

isPrivate

public static boolean isPrivate(int access)

isPublic

public static boolean isPublic(int access)

isProtected

public static boolean isProtected(int access)

isFinal

public static boolean isFinal(int access)

isSynthetic

public static boolean isSynthetic(int access)

isNative

public static boolean isNative(int access)

isStatic

public static boolean isStatic(int access)

isAbstract

public static boolean isAbstract(int access)

loadAsClassNode

public static org.objectweb.asm.tree.ClassNode loadAsClassNode(byte[] bytecode)

toBytecode

public static byte[] toBytecode(org.objectweb.asm.tree.ClassNode classNode)

getTmpDir

public static java.lang.String getTmpDir()

writeToFile

public static void writeToFile(java.io.File file,
                               byte[] bytecode)


Copyright © 2008-2010 Multiverse. All Rights Reserved.