public class ASMUtils
extends java.lang.Object
| Constructor and Description |
|---|
ASMUtils() |
| Modifier and Type | Method and Description |
|---|---|
static org.objectweb.asm.tree.ClassNode |
cloneClass(org.objectweb.asm.tree.ClassNode classNode)
Clone a
ClassNode |
static org.objectweb.asm.tree.MethodNode |
cloneMethod(org.objectweb.asm.tree.MethodNode methodNode)
Clone a
MethodNode |
static java.lang.String |
combiToRegex(java.lang.String combi)
Convert a field or method name matching name and descriptor to a regex pattern
Use * for wildcard e.g. |
static boolean |
compareType(org.objectweb.asm.Type type,
org.objectweb.asm.Type targetType)
Compare a single
Type with a target TypeThis supports Object instead of direct types |
static boolean |
compareTypes(org.objectweb.asm.Type[] types,
org.objectweb.asm.Type[] targetTypes)
Compare an array of
Type with a target array of TypeThis supports Object instead of direct types |
static boolean |
compareTypes(org.objectweb.asm.Type[] types,
org.objectweb.asm.Type[] targetTypes,
boolean prepend,
org.objectweb.asm.Type... additionalNeededTypes)
Compare an array of
Type with a target array of TypeThis supports Object instead of direct types |
static org.objectweb.asm.tree.ClassNode |
createEmptyClass(java.lang.String name)
Create an empty class with a default constructor
|
static org.objectweb.asm.tree.ClassNode |
fromBytes(byte[] bytecode)
Get a
ClassNode from the raw bytecode of a class |
static org.objectweb.asm.tree.InsnList |
getCast(org.objectweb.asm.Type wantedType)
Get the code to cast an
Object to any TypeConverts primitive wrapper to their primitive types (e.g. |
static org.objectweb.asm.tree.FieldNode |
getField(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Get a
FieldNode from a ClassNode using the name |
static java.util.List<org.objectweb.asm.tree.FieldNode> |
getFieldsFromCombi(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String combi)
Get a
List of FieldNodes from a ClassNode using the combined name and descriptorUse * for wildcard e.g. |
static org.objectweb.asm.tree.AbstractInsnNode |
getFirstConstructorInstruction(java.lang.String superClass,
org.objectweb.asm.tree.MethodNode methodNode)
Get the first instruction of a constructor
|
static int |
getFreeVarIndex(org.objectweb.asm.tree.MethodNode methodNode)
Get the last empty local variable index
|
static int |
getLoadOpcode(org.objectweb.asm.Type type)
Get the needed load opcode for a given
Type |
static org.objectweb.asm.tree.MethodNode |
getMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
Get a
MethodNode from a ClassNode using the name and descriptor |
static java.util.List<org.objectweb.asm.tree.MethodNode> |
getMethodsFromCombi(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String combi)
Get a
List of MethodNodes from a ClassNode using the combined name and descriptorUse * for wildcard e.g. |
static java.lang.Number |
getNumber(org.objectweb.asm.tree.AbstractInsnNode instruction)
Get a
Number from an AbstractInsnNode if it represents a Number |
static org.objectweb.asm.tree.AbstractInsnNode |
getPrimitiveToObject(org.objectweb.asm.Type primitive)
Get the code to wrap a primitive to their wrapper type (e.g.
|
static int |
getReturnOpcode(org.objectweb.asm.Type returnType)
Get the needed return opcode for a given
Type |
static int |
getStoreOpcode(org.objectweb.asm.Type type)
Get the needed store opcode for a given
Type |
static boolean |
isAccessLower(int toCheck,
int checkAgainst)
Check if the access is lower than another
|
static int |
setAccess(int currentAccess,
int newAccess)
Set the wanted access to a given access mask
|
static MemberDeclaration |
splitMemberDeclaration(java.lang.String injectDeclaration)
Split an injection declaration into owner, name and desc
|
static byte[] |
toBytes(org.objectweb.asm.tree.ClassNode node,
IClassProvider classProvider)
Get the bytecode from a
ClassNode |
public static org.objectweb.asm.tree.ClassNode fromBytes(byte[] bytecode)
ClassNode from the raw bytecode of a classbytecode - The bytecode of the classClassNodepublic static byte[] toBytes(org.objectweb.asm.tree.ClassNode node,
IClassProvider classProvider)
ClassNodenode - The ClassNodeclassProvider - The IClassProviderpublic static org.objectweb.asm.tree.MethodNode getMethod(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
MethodNode from a ClassNode using the name and descriptorclassNode - The owner ClassNodename - The name of the methoddesc - The descriptor of the methodMethodNodepublic static org.objectweb.asm.tree.FieldNode getField(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String name,
java.lang.String desc)
FieldNode from a ClassNode using the nameclassNode - The owner ClassNodename - The name of the fielddesc - The descriptor of the fieldFieldNodepublic static java.util.List<org.objectweb.asm.tree.MethodNode> getMethodsFromCombi(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String combi)
List of MethodNodes from a ClassNode using the combined name and descriptorclassNode - The owner ClassNodecombi - The combined name and descriptorList of MethodNodespublic static java.util.List<org.objectweb.asm.tree.FieldNode> getFieldsFromCombi(org.objectweb.asm.tree.ClassNode classNode,
java.lang.String combi)
List of FieldNodes from a ClassNode using the combined name and descriptorclassNode - The owner ClassNodecombi - The combined name and descriptorList of FieldNodespublic static java.lang.String combiToRegex(java.lang.String combi)
combi - The name of a field or methodpublic static boolean isAccessLower(int toCheck,
int checkAgainst)
toCheck - The access to checkcheckAgainst - The access to check againstpublic static int setAccess(int currentAccess,
int newAccess)
currentAccess - The current access masknewAccess - The wanted accesspublic static int getReturnOpcode(org.objectweb.asm.Type returnType)
TypereturnType - The return Type of a methodpublic static int getLoadOpcode(org.objectweb.asm.Type type)
Typetype - The Type to get the load opcode forpublic static int getStoreOpcode(org.objectweb.asm.Type type)
Typetype - The Type to get the store opcode forpublic static int getFreeVarIndex(org.objectweb.asm.tree.MethodNode methodNode)
methodNode - The method to get the last empty local variable index forpublic static org.objectweb.asm.tree.InsnList getCast(org.objectweb.asm.Type wantedType)
Object to any TypewantedType - The wanted TypeObject to any Typepublic static org.objectweb.asm.tree.AbstractInsnNode getPrimitiveToObject(org.objectweb.asm.Type primitive)
primitive - The primitive type to wrappublic static MemberDeclaration splitMemberDeclaration(java.lang.String injectDeclaration)
injectDeclaration - The injection declarationpublic static org.objectweb.asm.tree.AbstractInsnNode getFirstConstructorInstruction(java.lang.String superClass,
org.objectweb.asm.tree.MethodNode methodNode)
superClass - The name of the super classmethodNode - The MethodNode of the constructorpublic static java.lang.Number getNumber(org.objectweb.asm.tree.AbstractInsnNode instruction)
Number from an AbstractInsnNode if it represents a Numberinstruction - The AbstractInsnNodeNumber or null if it is not a Numberpublic static boolean compareTypes(org.objectweb.asm.Type[] types,
org.objectweb.asm.Type[] targetTypes)
Type with a target array of TypeObject instead of direct typestypes - The source array of TypetargetTypes - The target array of Typepublic static boolean compareTypes(org.objectweb.asm.Type[] types,
org.objectweb.asm.Type[] targetTypes,
boolean prepend,
org.objectweb.asm.Type... additionalNeededTypes)
Type with a target array of TypeObject instead of direct typestypes - The source array of TypetargetTypes - The target array of Typeprepend - If the additional Type array should be prepended or appendedadditionalNeededTypes - The additional Type to append to the sourcepublic static boolean compareType(org.objectweb.asm.Type type,
org.objectweb.asm.Type targetType)
Type with a target TypeObject instead of direct typestype - The source TypetargetType - The target Typepublic static org.objectweb.asm.tree.ClassNode cloneClass(org.objectweb.asm.tree.ClassNode classNode)
ClassNodeclassNode - The ClassNode to cloneClassNodepublic static org.objectweb.asm.tree.MethodNode cloneMethod(org.objectweb.asm.tree.MethodNode methodNode)
MethodNodemethodNode - The MethodNode to cloneMethodNodepublic static org.objectweb.asm.tree.ClassNode createEmptyClass(java.lang.String name)
name - The name of the classClassNode