Package io.quarkus.deployment.util
Class AsmUtil
- java.lang.Object
-
- io.quarkus.deployment.util.AsmUtil
-
public class AsmUtil extends Object
A collection of ASM and Jandex utilities.
-
-
Field Summary
Fields Modifier and Type Field Description static Map<Character,String>
PRIMITIVE_DESCRIPTOR_TO_PRIMITIVE_CLASS_LITERAL
static List<org.objectweb.asm.Type>
PRIMITIVES
static Map<org.objectweb.asm.Type,org.objectweb.asm.Type>
WRAPPER_TO_PRIMITIVE
static List<org.objectweb.asm.Type>
WRAPPERS
-
Constructor Summary
Constructors Constructor Description AsmUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static org.objectweb.asm.Type
autobox(org.objectweb.asm.Type primitive)
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.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 infostatic String
getDescriptor(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useMethodInfo.descriptor(Function)
static String
getDescriptor(org.jboss.jandex.Type type, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useType.descriptor(Function)
static int
getLoadOpcode(org.jboss.jandex.Type jandexType)
Returns the bytecode instruction to load the given Jandex Type.static int
getParameterSize(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 int
getReturnInstruction(String typeDescriptor)
Returns a return bytecode instruction suitable for the given return type descriptor.static int
getReturnInstruction(org.jboss.jandex.Type jandexType)
Returns a return bytecode instruction suitable for the given return Jandex Type.static String
getSignature(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useMethodInfo.genericSignature(Function)
static String
getSignature(org.jboss.jandex.Type type, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.forType(Type, Function, StringBuilder)
static String
getSignatureIfRequired(org.jboss.jandex.MethodInfo method)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.genericSignatureIfRequired()
static String
getSignatureIfRequired(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.genericSignatureIfRequired(Function)
static void
printValueOnStderr(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 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.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.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.
-
-
-
Method Detail
-
autobox
public static org.objectweb.asm.Type autobox(org.objectweb.asm.Type primitive)
-
getSignatureIfRequired
@Deprecated(since="3.1", forRemoval=true) public static String getSignatureIfRequired(org.jboss.jandex.MethodInfo method)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.genericSignatureIfRequired()
-
getSignatureIfRequired
@Deprecated(since="3.1", forRemoval=true) public static String getSignatureIfRequired(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.genericSignatureIfRequired(Function)
-
getSignature
@Deprecated(since="3.1", forRemoval=true) public static String getSignature(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useMethodInfo.genericSignature(Function)
-
getDescriptor
@Deprecated(since="3.1", forRemoval=true) public static String getDescriptor(org.jboss.jandex.MethodInfo method, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useMethodInfo.descriptor(Function)
-
getDescriptor
@Deprecated(since="3.1", forRemoval=true) public static String getDescriptor(org.jboss.jandex.Type type, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useType.descriptor(Function)
-
getSignature
@Deprecated(since="3.1", forRemoval=true) public static String getSignature(org.jboss.jandex.Type type, Function<String,String> typeArgMapper)
Deprecated, for removal: This API element is subject to removal in a future version.useGenericSignature.forType(Type, Function, StringBuilder)
-
getReturnInstruction
public static int getReturnInstruction(String typeDescriptor)
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
public static org.jboss.jandex.Type[] getParameterTypes(String methodDescriptor)
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
public static void printValueOnStderr(org.objectweb.asm.MethodVisitor mv, Runnable valuePusher)
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
-
-