public class ASMUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.util.Map<java.lang.Integer,java.lang.Class<?>> |
numericTypes |
Constructor and Description |
---|
ASMUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
byteCodeSpy(byte[] bytes)
Return the bytecode of the class
|
static java.lang.String |
byteCodeSpy(java.lang.Class<?> clazz)
Return the bytecode of the class
|
static java.lang.String |
byteCodeSpy(java.io.InputStream is)
Return the bytecode of the class
|
static java.lang.String |
checkClass(byte[] bytes)
Check if the class have errors
|
static int |
getAdd(java.lang.String type)
Calculates the add opcode from the type descriptor
|
static org.objectweb.asm.Type[] |
getArgumentTypes(org.objectweb.asm.tree.MethodNode methodNode)
Return the argument types of the method
|
static java.lang.String |
getASMified(byte[] bytes)
Returns the ASMified code of the class
|
static java.lang.String |
getASMified(java.lang.Class<?> clazz)
Returns the ASMified code of the class
|
static java.lang.String |
getASMified(java.io.InputStream is)
Returns the ASMified code of the class
|
static java.lang.Class<?> |
getClass(org.objectweb.asm.Type type)
This method transforms a
Type to Class object. |
static org.objectweb.asm.tree.ClassNode |
getClassNode(byte[] bytes)
This method obtain the
ClassNode of the given class bytes. |
static org.objectweb.asm.tree.ClassNode |
getClassNode(java.lang.Class<?> clazz)
This method obtain the
ClassNode of the given class. |
static org.objectweb.asm.tree.ClassNode |
getClassNode(java.io.InputStream is)
This method obtain the
ClassNode from a InputStream . |
static org.objectweb.asm.tree.ClassNode |
getClassNode(java.lang.String internalName)
This method obtain the
ClassNode from the internal name of the class
. |
static int |
getConst(java.lang.String type)
Calculates the constant opcode from the type descriptor
|
static void |
getConversion(java.lang.String type,
org.objectweb.asm.MethodVisitor mv)
Adds a conversion instruction whenever the type of the field is byte,
char or its wrapper types
|
static java.lang.String |
getDescriptor(java.lang.Class<?> clazz)
Obtains the descriptor of the class
|
static int |
getFirstAvailableIndex(java.lang.String methodDesc,
int index) |
static java.lang.String |
getInternalName(java.lang.Class<?> clazz)
Obtains the internal name of the class
|
static int |
getMaxStack(org.objectweb.asm.tree.MethodNode methodNode)
Return the max stack size for a method
|
static org.objectweb.asm.tree.MethodInsnNode |
getMethodInsnStatic(java.lang.String className,
java.lang.String methodName,
java.lang.String descriptor)
Obtains a static
MethodInsnNode |
static org.objectweb.asm.tree.VarInsnNode |
getParamInsn(org.objectweb.asm.Type type,
int number)
Create a
VarInsnNode from a Type and the index of the
parameter |
static org.objectweb.asm.tree.InsnNode |
getReturnInsn(org.objectweb.asm.tree.MethodNode methodNode)
Obtains the return node for one method
|
static int |
getReturnOpcode(java.lang.String methodDesc)
Return the return opcode for one method descriptor
|
static int |
getSub(java.lang.String type)
Calculates the sub opcode from the type descriptor
|
static void |
getValue(java.lang.String type,
org.objectweb.asm.MethodVisitor mv)
Adds the instruction to convert the wrapper type to primitive type when
the type of the field is a wrapper type
|
static void |
getValueOf(java.lang.String type,
org.objectweb.asm.MethodVisitor mv)
Adds the instruction to convert the primitive type to wrapper type when
the type of the field is a wrapper type
|
static org.objectweb.asm.tree.InsnList |
getVarInsnList(java.lang.String desc)
Obtains the
InsnList with the load of all parameters of the method. |
static org.objectweb.asm.tree.InsnList |
getVarInvokerInsnList(java.lang.String desc)
Obtains the
InsnList with the load of the parameters of the method
avoiding the first parameter. |
static int |
getVarOpcode(java.lang.String varDesc)
Obtains the var opcode for a descriptor
|
static boolean |
isStatic(org.objectweb.asm.tree.MethodNode methodNode)
Checks of the method is static
|
static int |
nextIndex(int index,
java.lang.String desc)
Calculates the next index
|
public static final java.util.Map<java.lang.Integer,java.lang.Class<?>> numericTypes
public static java.lang.Class<?> getClass(org.objectweb.asm.Type type)
Type
to Class
object.type
- The Type
object to transform.Class
represented by the Type
object or null if
the type doesn't represent a valid Class
.public static org.objectweb.asm.tree.ClassNode getClassNode(java.lang.Class<?> clazz)
ClassNode
of the given class.clazz
- The class which ClassNode
have to be returned.ClassNode
of the given class.public static org.objectweb.asm.tree.ClassNode getClassNode(byte[] bytes)
ClassNode
of the given class bytes.bytes
- The class which ClassNode
have to be returned.ClassNode
of the given class.public static org.objectweb.asm.tree.ClassNode getClassNode(java.io.InputStream is) throws java.io.IOException
ClassNode
from a InputStream
.is
- The stream to read the bytesClassNode
of the given class.java.io.IOException
- If there are problems with the streampublic static org.objectweb.asm.tree.ClassNode getClassNode(java.lang.String internalName) throws java.io.IOException
ClassNode
from the internal name of the class
.internalName
- The internal name of the classClassNode
of the given class.java.io.IOException
- If there are problems reading the classpublic static java.lang.String getASMified(java.lang.Class<?> clazz)
clazz
- The class to ASMifiedpublic static java.lang.String getASMified(byte[] bytes)
bytes
- The bytes of the class to ASMifiedpublic static java.lang.String getASMified(java.io.InputStream is) throws java.io.IOException
is
- The InputStream
to read the bytes of the class to ASMifiedjava.io.IOException
public static java.lang.String byteCodeSpy(java.lang.Class<?> clazz)
clazz
- The class to obtain the bytecodepublic static java.lang.String byteCodeSpy(byte[] bytes)
bytes
- The bytes of the class to obtain the bytecodepublic static java.lang.String byteCodeSpy(java.io.InputStream is) throws java.io.IOException
is
- The InputStream
to read the bytes of the class to obtain
the bytecodejava.io.IOException
public static int getMaxStack(org.objectweb.asm.tree.MethodNode methodNode)
methodNode
- Method to calculate max stackpublic static org.objectweb.asm.Type[] getArgumentTypes(org.objectweb.asm.tree.MethodNode methodNode)
methodNode
- The method nodepublic static org.objectweb.asm.tree.VarInsnNode getParamInsn(org.objectweb.asm.Type type, int number)
VarInsnNode
from a Type
and the index of the
parametertype
- Type of the varnumber
- Index of the varVarInsnNode
public static org.objectweb.asm.tree.MethodInsnNode getMethodInsnStatic(java.lang.String className, java.lang.String methodName, java.lang.String descriptor)
MethodInsnNode
className
- The internal name class that owns the methodmethodName
- The name of the methoddescriptor
- The descriptor of the methodpublic static org.objectweb.asm.tree.InsnNode getReturnInsn(org.objectweb.asm.tree.MethodNode methodNode)
methodNode
- The method nodepublic static boolean isStatic(org.objectweb.asm.tree.MethodNode methodNode)
methodNode
- The methodpublic static java.lang.String getDescriptor(java.lang.Class<?> clazz)
clazz
- The classpublic static java.lang.String getInternalName(java.lang.Class<?> clazz)
clazz
- The classpublic static int getReturnOpcode(java.lang.String methodDesc)
methodDesc
- Method descriptorpublic static int getVarOpcode(java.lang.String varDesc)
varDesc
- Descriptor of the varpublic static org.objectweb.asm.tree.InsnList getVarInsnList(java.lang.String desc)
InsnList
with the load of all parameters of the method.desc
- Descriptor of the methodVarInsnNode
of the parameterspublic static org.objectweb.asm.tree.InsnList getVarInvokerInsnList(java.lang.String desc)
InsnList
with the load of the parameters of the method
avoiding the first parameter.desc
- The descriptor of the methodVarInsnNode
of the parameterspublic static int nextIndex(int index, java.lang.String desc)
index
- Actual indexdesc
- Descriptor of the actual variablepublic static java.lang.String checkClass(byte[] bytes)
bytes
- Bytes of the classpublic static int getFirstAvailableIndex(java.lang.String methodDesc, int index)
methodDesc
- index
- public static void getValueOf(java.lang.String type, org.objectweb.asm.MethodVisitor mv)
type
- The type of the fieldmv
- The method where the instruction is addedpublic static int getAdd(java.lang.String type)
type
- The descriptor of the typepublic static int getSub(java.lang.String type)
type
- The descriptor of the typepublic static int getConst(java.lang.String type)
type
- The descriptor of the typepublic static void getConversion(java.lang.String type, org.objectweb.asm.MethodVisitor mv)
type
- The descriptor of the fieldmv
- The method to set conversion instructionpublic static void getValue(java.lang.String type, org.objectweb.asm.MethodVisitor mv)
type
- The type of the fieldmv
- The method where the instruction is added