public final class AsmUtils extends Object
Modifier and Type | Method and Description |
---|---|
static InsnList |
createArgumentLoaders(String methodDescriptor) |
static Class<?> |
findLoadedClass(String className,
ClassLoader classLoader)
Returns the class with the given name if it has already been loaded by
the given class loader.
|
static Constructor<?> |
getClassConstructor(String classInternalName,
String constructorDesc) |
static Field |
getClassField(String classInternalName,
String fieldName) |
static Class<?> |
getClassForType(Type type)
Get the class equivalent to an ASM
Type |
static Method |
getClassMethod(String classInternalName,
String methodName,
String methodDesc) |
static String |
getExtendedParserClassName(String parserClassName) |
static boolean |
isActionRoot(AbstractInsnNode insn) |
static boolean |
isActionRoot(String methodOwner,
String methodName) |
static boolean |
isAssignableTo(String classInternalName,
Class<?> type)
Determines whether the class with the given descriptor is assignable to the given type.
|
static boolean |
isBooleanValueOfZ(AbstractInsnNode insn) |
static boolean |
isBooleanValueOfZ(String methodOwner,
String methodName,
String methodDesc) |
static boolean |
isCallOnContextAware(AbstractInsnNode insn) |
static boolean |
isVarRoot(AbstractInsnNode insn) |
static boolean |
isVarRoot(String methodOwner,
String methodName,
String methodDesc) |
static Class<?> |
loadClass(String className,
byte[] code,
ClassLoader classLoader)
Loads the class defined with the given name and bytecode using the given
class loader
|
public static Class<?> getClassForType(Type type)
Type
type
- the typepublic static Method getClassMethod(String classInternalName, String methodName, String methodDesc)
public static Constructor<?> getClassConstructor(String classInternalName, String constructorDesc)
@Nullable public static Class<?> findLoadedClass(String className, ClassLoader classLoader)
className
- the full name of the class to be loadedclassLoader
- the class loader to usepublic static Class<?> loadClass(String className, byte[] code, ClassLoader classLoader)
Since package and class idendity includes the ClassLoader instance used to load a class, we use reflection on the given class loader to define generated classes.
If we used our own class loader (in order to be able to access the protected "defineClass" method), we would likely still be able to load generated classes; however, they would not have access to package-private classes and members of their super classes.
className
- the full name of the class to be loadedcode
- the bytecode of the class to loadclassLoader
- the class loader to usepublic static boolean isAssignableTo(String classInternalName, Class<?> type)
classInternalName
- the class descriptortype
- the typepublic static boolean isBooleanValueOfZ(AbstractInsnNode insn)
public static boolean isBooleanValueOfZ(String methodOwner, String methodName, String methodDesc)
public static boolean isActionRoot(AbstractInsnNode insn)
public static boolean isVarRoot(AbstractInsnNode insn)
public static boolean isCallOnContextAware(AbstractInsnNode insn)