Package org.apache.drill.exec.compile
Class AsmUtil
java.lang.Object
org.apache.drill.exec.compile.AsmUtil
Utilities commonly used with ASM.
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.
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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
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
Write a class to the log.static void
logClassFromBytes
(org.slf4j.Logger logger, String logTag, byte[] classBytes) Write a class to the log.
-
Method Details
-
isClassOk
public static boolean isClassOk(org.slf4j.Logger logger, String logTag, org.objectweb.asm.tree.ClassNode classNode) Check to see if a class is well-formed.- Parameters:
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 check- Returns:
- true if the class is ok, false otherwise
-
isClassBytesOk
Check to see if a class is well-formed.- Parameters:
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 check- Returns:
- true if the class is ok, false otherwise
-
classFromBytes
public static org.objectweb.asm.tree.ClassNode classFromBytes(byte[] classBytes, int asmReaderFlags) Create a ClassNode from bytecode.- Parameters:
classBytes
- the bytecodeasmReaderFlags
- flags for ASM; seeClassReader.accept(org.objectweb.asm.ClassVisitor, int)
- Returns:
- the ClassNode
-
logClass
public static void logClass(org.slf4j.Logger logger, String logTag, org.objectweb.asm.tree.ClassNode classNode) Write a class to the log.Writes at level TRACE.
- Parameters:
logger
- the logger to write tologTag
- a tag to print to the logclassNode
- the class
-
logClassFromBytes
Write a class to the log.Writes at level DEBUG.
- Parameters:
logTag
- a tag to print to the logclassBytes
- the class' bytecodelogger
- the logger to write to
-
isXconst
public static boolean isXconst(int opcode) Determine if the given opcode is a load of a constant (xCONST_y).- Parameters:
opcode
- the opcode- Returns:
- true if the opcode is one of the constant loading ones, false otherwise
-
isXadd
public static boolean isXadd(int opcode) Determine if the given opcode is an ADD of some kind (xADD).- Parameters:
opcode
- the opcode- Returns:
- true if the opcode is one of the ADDs, false otherwise
-