类 ReflectUtils


  • public final class ReflectUtils
    extends 
    ReflectUtils
    • 方法概要

      所有方法 静态方法 具体方法 
      修饰符和类型 方法 说明
      static <?>  desc)
      desc to class.
      static <?>[]  desc)
      get class array instance.
      static  desc)
      desc to name.
      static <?> <?> clazz, <?> paramType)  
      static <?> clazz,  methodName)  
      static <?> clazz,  methodName, [] parameterTypes)
      Find method from method signature
      static <?>  name)  
      static <,​>  cl)  
      static <,​>  cl)  
      static <?> <?> c)  
      static <?> cls)  
      static <?> c)
      get class desc.
      static <?>[] cs)
      get class array desc.
      static <?> c)
      get constructor desc. "()V", "(Ljava/lang/String;I)V"
      static  m)
      get method desc.
      static getDesc​(javassist.CtClass c)
      get class desc.
      static getDesc​(javassist.CtConstructor c)
      get constructor desc. "()V", "(Ljava/lang/String;I)V"
      static getDesc​(javassist.CtMethod m)
      get method desc.
      static  m)
      get method desc.
      static getDescWithoutMethodName​(javassist.CtMethod m)
      get method desc.
      static <?> returnType)  
      static <?> <?> cls)  
      static <?> <?> cls, int i)  
      static <?> c)
      get name.
      static <?> c)
      get constructor name. "()", "(java.lang.String,int)"
      static  m)
      get method name.
      static  method)  
      static  method)  
      static  methodName, <?>[] parameterTypes)  
      static boolean  method)  
      static boolean  method)  
      static boolean <?>[] cs, [] os)
      is compatible.
      static boolean <?> c,  o)
      is compatible.
      static boolean  obj,  interfaceClazzName)
      Check if one object is the implementation for a given interface.
      static boolean <?> cls)  
      static boolean <?> cls)  
      static boolean  field)  
      static <?>  name)
      name to class.
      static  name)
      name to desc.
      • 从类继承的方法 java.lang.

        , , , , , , , ,
    • 字段详细资料

      • JVM_VOID

        public static final char JVM_VOID
        void(V).
        另请参阅:
        常量字段值
      • JVM_BOOLEAN

        public static final char JVM_BOOLEAN
        boolean(Z).
        另请参阅:
        常量字段值
      • JVM_BYTE

        public static final char JVM_BYTE
        byte(B).
        另请参阅:
        常量字段值
      • JVM_CHAR

        public static final char JVM_CHAR
        char(C).
        另请参阅:
        常量字段值
      • JVM_DOUBLE

        public static final char JVM_DOUBLE
        double(D).
        另请参阅:
        常量字段值
      • JVM_FLOAT

        public static final char JVM_FLOAT
        float(F).
        另请参阅:
        常量字段值
      • JVM_INT

        public static final char JVM_INT
        int(I).
        另请参阅:
        常量字段值
      • JVM_LONG

        public static final char JVM_LONG
        long(J).
        另请参阅:
        常量字段值
      • JVM_SHORT

        public static final char JVM_SHORT
        short(S).
        另请参阅:
        常量字段值
      • EMPTY_CLASS_ARRAY

        public static final <?>[] EMPTY_CLASS_ARRAY
      • JAVA_IDENT_REGEX

        public static final  JAVA_IDENT_REGEX
        另请参阅:
        常量字段值
      • JAVA_NAME_REGEX

        public static final  JAVA_NAME_REGEX
        另请参阅:
        常量字段值
      • CLASS_DESC

        public static final  CLASS_DESC
        另请参阅:
        常量字段值
      • ARRAY_DESC

        public static final  ARRAY_DESC
        另请参阅:
        常量字段值
      • DESC_REGEX

        public static final  DESC_REGEX
        另请参阅:
        常量字段值
      • DESC_PATTERN

        public static final  DESC_PATTERN
      • METHOD_DESC_REGEX

        public static final  METHOD_DESC_REGEX
        另请参阅:
        常量字段值
      • METHOD_DESC_PATTERN

        public static final  METHOD_DESC_PATTERN
      • GETTER_METHOD_DESC_PATTERN

        public static final  GETTER_METHOD_DESC_PATTERN
      • SETTER_METHOD_DESC_PATTERN

        public static final  SETTER_METHOD_DESC_PATTERN
      • IS_HAS_CAN_METHOD_DESC_PATTERN

        public static final  IS_HAS_CAN_METHOD_DESC_PATTERN
    • 方法详细资料

      • isPrimitives

        public static boolean isPrimitives​(<?> cls)
      • isPrimitive

        public static boolean isPrimitive​(<?> cls)
      • getBoxedClass

        public static <?> getBoxedClass​(<?> c)
      • isCompatible

        public static boolean isCompatible​(<?> c,
                                            o)
        is compatible.
        参数:
        c - class.
        o - instance.
        返回:
        compatible or not.
      • isCompatible

        public static boolean isCompatible​(<?>[] cs,
                                           [] os)
        is compatible.
        参数:
        cs - class array.
        os - object array.
        返回:
        compatible or not.
      • getCodeBase

        public static  getCodeBase​(<?> cls)
      • getName

        public static  getName​(<?> c)
        get name. java.lang.Object[][].class => "java.lang.Object[][]"
        参数:
        c - class.
        返回:
        name.
      • getGenericClass

        public static <?> getGenericClass​(<?> cls)
      • getGenericClass

        public static <?> getGenericClass​(<?> cls,
                                               int i)
      • getName

        public static  getName​( m)
        get method name. "void do(int)", "void do()", "int do(java.lang.String,boolean)"
        参数:
        m - method.
        返回:
        name.
      • getSignature

        public static  getSignature​( methodName,
                                          <?>[] parameterTypes)
      • getName

        public static  getName​(<?> c)
        get constructor name. "()", "(java.lang.String,int)"
        参数:
        c - constructor.
        返回:
        name.
      • getDesc

        public static  getDesc​(<?> c)
        get class desc. boolean[].class => "[Z" Object.class => "Ljava/lang/Object;"
        参数:
        c - class.
        返回:
        desc.
        抛出:
        javassist.NotFoundException
      • getDesc

        public static  getDesc​(<?>[] cs)
        get class array desc. [int.class, boolean[].class, Object.class] => "I[ZLjava/lang/Object;"
        参数:
        cs - class array.
        返回:
        desc.
        抛出:
        javassist.NotFoundException
      • getDesc

        public static  getDesc​( m)
        get method desc. int do(int arg1) => "do(I)I" void do(String arg1,boolean arg2) => "do(Ljava/lang/String;Z)V"
        参数:
        m - method.
        返回:
        desc.
      • getDesc

        public static  getDesc​(<?> c)
        get constructor desc. "()V", "(Ljava/lang/String;I)V"
        参数:
        c - constructor.
        返回:
        desc
      • getDescWithoutMethodName

        public static  getDescWithoutMethodName​( m)
        get method desc. "(I)I", "()V", "(Ljava/lang/String;Z)V"
        参数:
        m - method.
        返回:
        desc.
      • getDesc

        public static  getDesc​(javassist.CtClass c)
                              throws javassist.NotFoundException
        get class desc. Object.class => "Ljava/lang/Object;" boolean[].class => "[Z"
        参数:
        c - class.
        返回:
        desc.
        抛出:
        javassist.NotFoundException
      • getDesc

        public static  getDesc​(javassist.CtMethod m)
                              throws javassist.NotFoundException
        get method desc. "do(I)I", "do()V", "do(Ljava/lang/String;Z)V"
        参数:
        m - method.
        返回:
        desc.
        抛出:
        javassist.NotFoundException
      • getDesc

        public static  getDesc​(javassist.CtConstructor c)
                              throws javassist.NotFoundException
        get constructor desc. "()V", "(Ljava/lang/String;I)V"
        参数:
        c - constructor.
        返回:
        desc
        抛出:
        javassist.NotFoundException
      • getDescWithoutMethodName

        public static  getDescWithoutMethodName​(javassist.CtMethod m)
                                               throws javassist.NotFoundException
        get method desc. "(I)I", "()V", "(Ljava/lang/String;Z)V".
        参数:
        m - method.
        返回:
        desc.
        抛出:
        javassist.NotFoundException
      • name2desc

        public static  name2desc​( name)
        name to desc. java.util.Map[][] => "[[Ljava/util/Map;"
        参数:
        name - name.
        返回:
        desc.
      • desc2name

        public static  desc2name​( desc)
        desc to name. "[[I" => "int[][]"
        参数:
        desc - desc.
        返回:
        name.
      • forName

        public static <?> forName​( name)
      • name2class

        public static <?> name2class​( name)
                                   throws 
        name to class. "boolean" => boolean.class "java.util.Map[][]" => java.util.Map[][].class
        参数:
        name - name.
        返回:
        Class instance.
        抛出:
      • desc2class

        public static <?> desc2class​( desc)
                                   throws 
        desc to class. "[Z" => boolean[].class "[[Ljava/util/Map;" => java.util.Map[][].class
        参数:
        desc - desc.
        返回:
        Class instance.
        抛出:
      • desc2classArray

        public static <?>[] desc2classArray​( desc)
                                          throws 
        get class array instance.
        参数:
        desc - desc.
        返回:
        Class class array.
        抛出:
      • findMethodByMethodSignature

        public static  findMethodByMethodSignature​(<?> clazz,
                                                          methodName,
                                                         [] parameterTypes)
                                                  throws ,
                                                         
        Find method from method signature
        参数:
        clazz - Target class to find method
        methodName - Method signature, e.g.: method1(int, String). It is allowed to provide method name only, e.g.: method2
        返回:
        target method
        抛出:
        - when multiple methods are found (overridden method when parameter info is not provided)
      • findMethodByMethodName

        public static  findMethodByMethodName​(<?> clazz,
                                                     methodName)
                                             throws ,
                                                    
        抛出:
      • findConstructor

        public static <?> findConstructor​(<?> clazz,
                                                     <?> paramType)
                                              throws 
        抛出:
      • isInstance

        public static boolean isInstance​( obj,
                                          interfaceClazzName)
        Check if one object is the implementation for a given interface.

        This method will not trigger classloading for the given interface, therefore it will not lead to error when the given interface is not visible by the classloader

        参数:
        obj - Object to examine
        interfaceClazzName - The given interface
        返回:
        true if the object implements the given interface, otherwise return false
      • getEmptyObject

        public static  getEmptyObject​(<?> returnType)
      • isBeanPropertyReadMethod

        public static boolean isBeanPropertyReadMethod​( method)
      • getPropertyNameFromBeanReadMethod

        public static  getPropertyNameFromBeanReadMethod​( method)
      • isBeanPropertyWriteMethod

        public static boolean isBeanPropertyWriteMethod​( method)
      • getPropertyNameFromBeanWriteMethod

        public static  getPropertyNameFromBeanWriteMethod​( method)
      • isPublicInstanceField

        public static boolean isPublicInstanceField​( field)
      • getBeanPropertyFields

        public static <,​> getBeanPropertyFields​( cl)
      • getBeanPropertyReadMethods

        public static <,​> getBeanPropertyReadMethods​( cl)