Class AsmUtil


  • public class AsmUtil
    extends Object
    A collection of ASM and Jandex utilities. NOTE: this has a copy in AsmUtilCopy in arc-processor with some extra methods for knowing if we need a signature and getting the signature of a class.
    • Constructor Detail

      • AsmUtil

        public AsmUtil()
    • Method Detail

      • getDescriptor

        public static String getDescriptor​(org.jboss.jandex.MethodInfo method,
                                           Function<String,​String> typeArgMapper)
        Returns the Java bytecode descriptor of a given Jandex MethodInfo using the given type argument mappings. For example, given this method:
         
         public class Foo<T> {
          public <R> List<R> method(int a, T t){...}
         }
         
         
        This will return (ILjava/lang/Integer;)Ljava/util/List; if your typeArgMapper contains T=Ljava/lang/Integer;.
        Parameters:
        method - the method you want the descriptor for.
        typeArgMapper - a mapping between type argument names and their bytecode descriptor.
        Returns:
        a bytecode descriptor for that method.
      • getDescriptor

        public static String getDescriptor​(org.jboss.jandex.Type type,
                                           Function<String,​String> typeArgMapper)
        Returns the Java bytecode descriptor of a given Jandex Type using the given type argument mappings. For example, given this type: List<T>, this will return Ljava/util/List; if your typeArgMapper contains T=Ljava/lang/Integer;.
        Parameters:
        type - the type you want the descriptor for.
        typeArgMapper - a mapping between type argument names and their bytecode descriptor.
        Returns:
        a bytecode descriptor for that type.
      • getSignature

        public static String getSignature​(org.jboss.jandex.Type type,
                                          Function<String,​String> typeArgMapper)
        Returns the Java bytecode signature of a given Jandex Type using the given type argument mappings. For example, given this type: List<T>, this will return Ljava/util/List<Ljava/lang/Integer;>; if your typeArgMapper contains T=Ljava/lang/Integer;.
        Parameters:
        type - the type you want the signature for.
        typeArgMapper - a mapping between type argument names and their bytecode descriptor.
        Returns:
        a bytecode signature for that 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 instructions
        jandexType - 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 instructions
        type - The Jandex Type to unbox if it is a primitive.