public class AsmUtil extends Object
There are several class verification utilities which use CheckClassAdapter (DrillCheckClassAdapter) to ensure classes are well-formed; these are packaged as boolean functions so that they can be used in assertions.
Modifier and Type | Method and Description |
---|---|
static org.objectweb.asm.tree.ClassNode |
classFromBytes(byte[] classBytes,
int asmReaderFlags)
Create a ClassNode from bytecode.
|
static boolean |
isClassBytesOk(org.slf4j.Logger logger,
String logTag,
byte[] classBytes)
Check to see if a class is well-formed.
|
static boolean |
isClassOk(org.slf4j.Logger logger,
String logTag,
org.objectweb.asm.tree.ClassNode classNode)
Check to see if a class is well-formed.
|
static boolean |
isXadd(int opcode)
Determine if the given opcode is an ADD of some kind (xADD).
|
static boolean |
isXconst(int opcode)
Determine if the given opcode is a load of a constant (xCONST_y).
|
static void |
logClass(org.slf4j.Logger logger,
String logTag,
org.objectweb.asm.tree.ClassNode classNode)
Write a class to the log.
|
static void |
logClassFromBytes(org.slf4j.Logger logger,
String logTag,
byte[] classBytes)
Write a class to the log.
|
public static boolean isClassOk(org.slf4j.Logger logger, String logTag, org.objectweb.asm.tree.ClassNode classNode)
logger
- the logger to write to if a problem is foundlogTag
- a tag to print to the log if a problem is foundclassNode
- the class to checkpublic static boolean isClassBytesOk(org.slf4j.Logger logger, String logTag, byte[] classBytes)
logger
- the logger to write to if a problem is foundlogTag
- a tag to print to the log if a problem is foundclassBytes
- the bytecode of the class to checkpublic static org.objectweb.asm.tree.ClassNode classFromBytes(byte[] classBytes, int asmReaderFlags)
classBytes
- the bytecodeasmReaderFlags
- flags for ASM; see ClassReader.accept(org.objectweb.asm.ClassVisitor, int)
public static void logClass(org.slf4j.Logger logger, String logTag, org.objectweb.asm.tree.ClassNode classNode)
Writes at level TRACE.
logger
- the logger to write tologTag
- a tag to print to the logclassNode
- the classpublic static void logClassFromBytes(org.slf4j.Logger logger, String logTag, byte[] classBytes)
Writes at level DEBUG.
logTag
- a tag to print to the logclassBytes
- the class' bytecodelogger
- the logger to write topublic static boolean isXconst(int opcode)
opcode
- the opcodepublic static boolean isXadd(int opcode)
opcode
- the opcodeCopyright © 1970 The Apache Software Foundation. All rights reserved.