Package io.quarkus.deployment.util
Class AsmUtil
java.lang.Object
io.quarkus.deployment.util.AsmUtil
A collection of ASM and Jandex utilities.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.objectweb.asm.Typeautobox(org.objectweb.asm.Type primitive) static voidboxIfRequired(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Calls the right boxing method for the given Jandex Type if it is a primitive.static voidcopyParameterNames(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.MethodInfo method) Copy the parameter names to the given MethodVisitor, unless we don't have parameter name infostatic intgetLoadOpcode(org.jboss.jandex.Type jandexType) Returns the bytecode instruction to load the given Jandex Type.static intgetParameterSize(org.jboss.jandex.Type paramType) Returns the number of underlying bytecode parameters taken by the given Jandex parameter Type.static org.jboss.jandex.Type[]getParameterTypes(String methodDescriptor) Returns the Jandex Types of the parameters of the given method descriptor.static intgetReturnInstruction(String typeDescriptor) Returns a return bytecode instruction suitable for the given return type descriptor.static intgetReturnInstruction(org.jboss.jandex.Type jandexType) Returns a return bytecode instruction suitable for the given return Jandex Type.static voidprintValueOnStderr(org.objectweb.asm.MethodVisitor mv, Runnable valuePusher) Prints the value pushed on the stack (must be an Object) by the given valuePusher to STDERR.static voidunboxIfRequired(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Calls the right unboxing method for the given Jandex Type if it is a primitive.static voidunboxIfRequired(org.objectweb.asm.MethodVisitor mv, org.objectweb.asm.Type type) Calls the right unboxing method for the given Jandex Type if it is a primitive.static voidvisitLdc(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Invokes the proper LDC Class Constant instructions for the given Jandex Type.
-
Field Details
-
ASM_API_VERSION
public static final int ASM_API_VERSION- See Also:
-
PRIMITIVES
-
WRAPPERS
-
WRAPPER_TO_PRIMITIVE
-
PRIMITIVE_DESCRIPTOR_TO_PRIMITIVE_CLASS_LITERAL
-
-
Constructor Details
-
AsmUtil
public AsmUtil()
-
-
Method Details
-
autobox
public static org.objectweb.asm.Type autobox(org.objectweb.asm.Type primitive) -
getReturnInstruction
Returns a return bytecode instruction suitable for the given return type descriptor. This will return specialised return instructions IRETURN, LRETURN, FRETURN, DRETURN, RETURN for primitives/void, and ARETURN otherwise;- Parameters:
typeDescriptor- the return type descriptor.- Returns:
- the correct bytecode return instruction for that return type descriptor.
-
getReturnInstruction
public static int getReturnInstruction(org.jboss.jandex.Type jandexType) Returns a return bytecode instruction suitable for the given return Jandex Type. This will return specialised return instructions IRETURN, LRETURN, FRETURN, DRETURN, RETURN for primitives/void, and ARETURN otherwise;- Parameters:
jandexType- the return Jandex Type.- Returns:
- the correct bytecode return instruction for that return type descriptor.
-
visitLdc
public static void visitLdc(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Invokes the proper LDC Class Constant instructions for the given Jandex Type. This will properly create LDC instructions for array types, class/parameterized classes, and primitive types by loading their equivalent TYPE constants in their box types, as well as type variables (using the first bound or Object) and Void.- Parameters:
mv- The MethodVisitor on which to visit the LDC instructionsjandexType- the Jandex Type whose Class Constant to load.
-
boxIfRequired
public static void boxIfRequired(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Calls the right boxing method for the given Jandex Type if it is a primitive.- Parameters:
mv- The MethodVisitor on which to visit the boxing instructionsjandexType- The Jandex Type to box if it is a primitive.
-
getLoadOpcode
public static int getLoadOpcode(org.jboss.jandex.Type jandexType) Returns the bytecode instruction to load the given Jandex Type. This returns the specialised bytecodes ILOAD, DLOAD, FLOAD and LLOAD for primitives, or ALOAD otherwise.- Parameters:
jandexType- The Jandex Type whose load instruction to return.- Returns:
- The bytecode instruction to load the given Jandex Type.
-
unboxIfRequired
public static void unboxIfRequired(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.Type jandexType) Calls the right unboxing method for the given Jandex Type if it is a primitive.- Parameters:
mv- The MethodVisitor on which to visit the unboxing instructionsjandexType- The Jandex Type to unbox if it is a primitive.
-
unboxIfRequired
public static void unboxIfRequired(org.objectweb.asm.MethodVisitor mv, org.objectweb.asm.Type type) Calls the right unboxing method for the given Jandex Type if it is a primitive.- Parameters:
mv- The MethodVisitor on which to visit the unboxing instructionstype- The Jandex Type to unbox if it is a primitive.
-
getParameterTypes
Returns the Jandex Types of the parameters of the given method descriptor.- Parameters:
methodDescriptor- a method descriptor- Returns:
- the list of Jandex Type objects representing the parameters of the given method descriptor.
-
getParameterSize
public static int getParameterSize(org.jboss.jandex.Type paramType) Returns the number of underlying bytecode parameters taken by the given Jandex parameter Type. This will be 2 for doubles and longs, 1 otherwise.- Parameters:
paramType- the Jandex parameter Type- Returns:
- the number of underlying bytecode parameters required.
-
printValueOnStderr
Prints the value pushed on the stack (must be an Object) by the given valuePusher to STDERR.- Parameters:
mv- The MethodVisitor to forward printing to.valuePusher- The function to invoke to push an Object to print on the stack.
-
copyParameterNames
public static void copyParameterNames(org.objectweb.asm.MethodVisitor mv, org.jboss.jandex.MethodInfo method) Copy the parameter names to the given MethodVisitor, unless we don't have parameter name info- Parameters:
mv- the visitor to copy tomethod- the method to copy from
-