Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## de.grogra.reflect
Class Reflection

    java.lang.Object
      de.grogra.reflect.Reflection

    public final class Reflection

extends java.lang.Object

Method Summary
`static boolean` | `canLoad(java.lang.ClassLoader loader, java.lang.Class cls)`
`static boolean` | `equal(java.lang.Class t1, Type t2)`
`static boolean` | `equal(Signature s1, Signature s2)`
`static boolean` | `equal(Type t1, Type t2)`
`static Member` | `find(Member[] members, java.lang.String nameOrDescriptor)`
`static Field` | `findFieldInClasses(Type type, java.lang.String nameOrDescriptor)`
`static Type` | `findFirst(Type[] types, Type type)`
`static Method` | `findMethodInClasses(Type type, java.lang.String name)`
`static Method` | `findMethodWithPrefixInTypes(Type type, java.lang.String descriptorPrefix, boolean includeInterfaces, boolean publicOnly)`
`static java.lang.Object` | `get(java.lang.Object object, Field field)`
`static Type<?>` | `getBinaryType(Type<?> type)`
`static
`<T extends java.lang.annotation.Annotation> Annotation<T>`
` | `getDeclaredAnnotation(Member member, java.lang.Class<T> cls)`
`static Field` | `getDeclaredField(Type type, java.lang.String nameOrDescriptor)`
`static Field[]` | `getDeclaredFields(Type type)`
`static Type[]` | `getDeclaredInterfaces(Type type)`
`static Method` | `getDeclaredMethod(Type type, java.lang.String nameOrDescriptor)`
`static Method[]` | `getDeclaredMethods(Type type)`
`static Type` | `getDeclaredType(Type type, java.lang.String nameOrDescriptor)`
`static Type[]` | `getDeclaredTypes(Type type)`
`static Method` | `getDefaultConstructor(Type type)`
`static java.lang.String` | `getDescription(Member m)`
`static java.lang.String` | `getDescriptor(Type[] types)`
`static int` | `getDimensionCount(Type type)`
`static Method` | `getElementMethod(Type type, java.lang.String element)`
`static Type` | `getEnclosingType(Type inner, Member member)` Returns the innermost of the enclosing types of `inner` of which `member` is a member.
`static Type[]` | `getExceptions(Method method)`
`static java.lang.String` | `getFieldDescriptor(java.lang.String name, Type type)`
`static char` | `getJVMPrefix(int typeId)`
`static char` | `getJVMPrefix(Type type)`
`static int` | `getJVMStackSize(Type type)` Returns the number of stack elements which are needed for the storage of values of the given `type` within the Java virtual machine.
`static int` | `getJVMStackSize(Type[] types)`
`static int` | `getJVMTypeId(Type type)`
`static java.lang.String` | `getMethodDescriptor(java.lang.String name, Type returnType, Type[] parameterTypes)`
`static Method` | `getMostSpecificPublicConstructor(Type type, java.lang.Object value)`
`static Type` | `getParameterType(Signature m, int index, boolean varArity)`
`static Type[]` | `getParameterTypes(Signature m)`
`static Type` | `getPublicType(Type[] types)`
`static java.lang.String` | `getSyntheticName(Member[] members, java.lang.String name)`
`static Type` | `getTopLevelType(Type type)`
`static Type` | `getType(java.lang.Class cls)`
`static Type` | `getType(int typeId)`
`static Type` | `getType(java.lang.Object object)`
`static Type` | `getType(java.lang.String type, java.lang.ClassLoader loader)`
`static java.lang.String` | `getTypeName(int typeId)`
`static java.lang.String` | `getTypeSuffix(int typeId)`
`static Type` | `getUnwrappedType(Type type)` If the input type is one of the wrapper classes (Boolean, Byte, Short, Integer, Long, Float, Double, Character), return the matching unwrapped type (boolean, byte, short, int, long, float, double, char), otherwise return Type.INVALID instead.
`static java.lang.Class` | `getWrapperClass(int typeId)`
`static boolean` | `hasCategory2(int typeId)`
`static boolean` | `hasDefaultAccess(Member m)`
`static boolean` | `incompatibleReturnTypesExist(Type t1, Type t2)`
`static boolean` | `isAbstract(Member m)`
`static boolean` | `isAccessible(Member m, Type instance, Type scope)` Determines if member `m` is accessible on `instance` in the context `scope`.
`static boolean` | `isAncestorOrSame(java.lang.ClassLoader a, java.lang.ClassLoader b)`
`static boolean` | `isArray(Type type)`
`static boolean` | `isAssignableFrom(Type target, Type source)`
`static boolean` | `isCastableFrom(Type target, Type source)`
`static boolean` | `isCtor(Method m)` Returns true if the method m is a constructor, otherwise returns false.
`static boolean` | `isFinal(Member m)`
`static boolean` | `isInner(Type m)`
`static boolean` | `isIntegral(Type type)`
`static boolean` | `isInterface(Type type)`
`static boolean` | `isInvalid(Type type)`
`static boolean` | `isMember(Member member, Type type)` Returns `true` iff `member` is a member of `type`.
`static boolean` | `isMoreVisible(int mods1, int mods2)`
`static boolean` | `isPrimitive(Type type)`
`static boolean` | `isPrimitiveOrString(Type type)`
`static boolean` | `isPrimitiveOrVoid(Type type)`
`static boolean` | `isPrivate(Member m)`
`static boolean` | `isProtected(Member m)`
`static boolean` | `isPublic(Member m)`
`static boolean` | `isStatic(Member m)`
`static boolean` | `isSuperclassOrSame(java.lang.Class sup, Type type)`
`static boolean` | `isSuperclassOrSame(java.lang.String sup, Type type)`
`static boolean` | `isSuperclassOrSame(Type sup, Type type)`
`static boolean` | `isSupertype(Type sup, Type type)`
`static boolean` | `isSupertypeOrSame(java.lang.Class sup, Type type)`
`static boolean` | `isSupertypeOrSame(java.lang.String sup, Type type)`
`static boolean` | `isSupertypeOrSame(Type sup, Type type)`
`static boolean` | `isWideningConversion(int src, int dest)`
`static boolean` | `isWideningConversion(Type src, Type dest)`
`static boolean` | `membersEqual(Member m1, Member m2, boolean ignoreDeclaringType)`
`static java.lang.String` | `modifiersToString(int mods)`
`static boolean` | `overlaps(FieldChain a, int[] aindices, FieldChain b, int[] bindices)`
`static void` | `set(java.lang.Object object, Field field, java.lang.Object value)`
`static java.lang.String` | `toString(Field field)`
`static java.lang.String` | `toString(Type t)`
`static java.lang.Object` | `toType(java.lang.Object v, Type t)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### canLoad

    public static boolean canLoad(java.lang.ClassLoader loader,
                                  java.lang.Class cls)

### equal

    public static boolean equal(java.lang.Class t1,
                                Type t2)

### equal

    public static boolean equal(Signature s1,
                                Signature s2)

### equal

    public static boolean equal(Type t1,
                                Type t2)

### find

    public static Member find(Member[] members,
                              java.lang.String nameOrDescriptor)

### findFieldInClasses

    public static Field findFieldInClasses(Type type,
                                           java.lang.String nameOrDescriptor)

### findFirst

    public static Type findFirst(Type[] types,
                                 Type type)

### findMethodInClasses

    public static Method findMethodInClasses(Type type,
                                             java.lang.String name)

### findMethodWithPrefixInTypes

    public static Method findMethodWithPrefixInTypes(Type type,
                                                     java.lang.String descriptorPrefix,
                                                     boolean includeInterfaces,
                                                     boolean publicOnly)

### get

    public static java.lang.Object get(java.lang.Object object,
                                       Field field)
                                throws java.lang.IllegalAccessException

  Throws:
    `java.lang.IllegalAccessException`

### getBinaryType

    public static Type<?> getBinaryType(Type<?> type)

### getDeclaredAnnotation

    public static <T extends java.lang.annotation.Annotation> Annotation<T> getDeclaredAnnotation(Member member,
                                                                                                  java.lang.Class<T> cls)

### getDeclaredField

    public static Field getDeclaredField(Type type,
                                         java.lang.String nameOrDescriptor)

### getDeclaredFields

    public static Field[] getDeclaredFields(Type type)

### getDeclaredInterfaces

    public static Type[] getDeclaredInterfaces(Type type)

### getDeclaredMethod

    public static Method getDeclaredMethod(Type type,
                                           java.lang.String nameOrDescriptor)

### getDeclaredMethods

    public static Method[] getDeclaredMethods(Type type)

### getDeclaredType

    public static Type getDeclaredType(Type type,
                                       java.lang.String nameOrDescriptor)

### getDeclaredTypes

    public static Type[] getDeclaredTypes(Type type)

### getDefaultConstructor

    public static Method getDefaultConstructor(Type type)

### getDescription

    public static java.lang.String getDescription(Member m)

### getDescriptor

    public static java.lang.String getDescriptor(Type[] types)

### getDimensionCount

    public static int getDimensionCount(Type type)

### getElementMethod

    public static Method getElementMethod(Type type,
                                          java.lang.String element)

### getEnclosingType

    public static Type getEnclosingType(Type inner,
                                        Member member)

  Returns the innermost of the enclosing types of `inner` of which `member` is a member. May be `inner` itself. Returns `null` if no such type can be found.

  Parameters:
    `inner` - a type
    `member` - a member
  Returns:
    innermost enclosing type of `inner` which has `member` as member

### getExceptions

    public static Type[] getExceptions(Method method)

### getFieldDescriptor

    public static java.lang.String getFieldDescriptor(java.lang.String name,
                                                      Type type)

### getJVMPrefix

    public static char getJVMPrefix(int typeId)

### getJVMPrefix

    public static char getJVMPrefix(Type type)

### getJVMStackSize

    public static int getJVMStackSize(Type type)

  Returns the number of stack elements which are needed for the storage of values of the given `type` within the Java virtual machine.

  Parameters:
    `type` - a type
  Returns:
    the required size in terms of stack elements

### getJVMStackSize

    public static int getJVMStackSize(Type[] types)

### getJVMTypeId

    public static int getJVMTypeId(Type type)

### getMethodDescriptor

    public static java.lang.String getMethodDescriptor(java.lang.String name,
                                                       Type returnType,
                                                       Type[] parameterTypes)

### getMostSpecificPublicConstructor

    public static Method getMostSpecificPublicConstructor(Type type,
                                                          java.lang.Object value)

### getParameterType

    public static Type getParameterType(Signature m,
                                        int index,
                                        boolean varArity)

### getParameterTypes

    public static Type[] getParameterTypes(Signature m)

### getPublicType

    public static Type getPublicType(Type[] types)

### getSyntheticName

    public static java.lang.String getSyntheticName(Member[] members,
                                                    java.lang.String name)

### getTopLevelType

    public static Type getTopLevelType(Type type)

### getType

    public static Type getType(java.lang.Class cls)

### getType

    public static Type getType(int typeId)

### getType

    public static final Type getType(java.lang.Object object)

### getType

    public static Type getType(java.lang.String type,
                               java.lang.ClassLoader loader)

### getTypeName

    public static java.lang.String getTypeName(int typeId)

### getTypeSuffix

    public static java.lang.String getTypeSuffix(int typeId)

### getUnwrappedType

    public static Type getUnwrappedType(Type type)

  If the input type is one of the wrapper classes (Boolean, Byte, Short, Integer, Long, Float, Double, Character), return the matching unwrapped type (boolean, byte, short, int, long, float, double, char), otherwise return Type.INVALID instead.

  Parameters:
    `type` -
  Returns:
    unwrapped type

### getWrapperClass

    public static java.lang.Class getWrapperClass(int typeId)

### hasCategory2

    public static boolean hasCategory2(int typeId)

### hasDefaultAccess

    public static boolean hasDefaultAccess(Member m)

### incompatibleReturnTypesExist

    public static boolean incompatibleReturnTypesExist(Type t1,
                                                       Type t2)

### isAbstract

    public static boolean isAbstract(Member m)

### isAccessible

    public static boolean isAccessible(Member m,
                                       Type instance,
                                       Type scope)

  Determines if member `m` is accessible on `instance` in the context `scope`. `instance` is only needed for instance methods and fields and denotes the instance on which these members are accessed. `scope` defines the type in whose declaration the access of `m` occurs.
  NOTE: This method does not check if the declaring type of `m` is accessible.

  Parameters:
    `m` - a member
    `instance` - instance for instance methods and fields
    `scope` - type in whose declaration `m` is accessed
  Returns:
    `true` iff the access is permitted

### isAncestorOrSame

    public static boolean isAncestorOrSame(java.lang.ClassLoader a,
                                           java.lang.ClassLoader b)

### isArray

    public static boolean isArray(Type type)

### isAssignableFrom

    public static boolean isAssignableFrom(Type target,
                                           Type source)

### isCastableFrom

    public static boolean isCastableFrom(Type target,
                                         Type source)

### isCtor

    public static boolean isCtor(Method m)

  Returns true if the method m is a constructor, otherwise returns false.

  Parameters:
    `m` - a method
  Returns:
    `true` iff `m` is a constructor

### isFinal

    public static boolean isFinal(Member m)

### isInner

    public static boolean isInner(Type m)

### isIntegral

    public static boolean isIntegral(Type type)

### isInterface

    public static boolean isInterface(Type type)

### isInvalid

    public static boolean isInvalid(Type type)

### isMember

    public static boolean isMember(Member member,
                                   Type type)

  Returns `true` iff `member` is a member of `type`. This is the case if `member` is declared in `type` or one of its supertypes.

  Parameters:
    `member` - a member
    `type` - a type
  Returns:
    `true` iff `member` is a member of `type`

### isMoreVisible

    public static boolean isMoreVisible(int mods1,
                                        int mods2)

### isPrimitive

    public static boolean isPrimitive(Type type)

### isPrimitiveOrString

    public static boolean isPrimitiveOrString(Type type)

### isPrimitiveOrVoid

    public static boolean isPrimitiveOrVoid(Type type)

### isPrivate

    public static boolean isPrivate(Member m)

### isProtected

    public static boolean isProtected(Member m)

### isPublic

    public static boolean isPublic(Member m)

### isStatic

    public static boolean isStatic(Member m)

### isSuperclassOrSame

    public static boolean isSuperclassOrSame(java.lang.Class sup,
                                             Type type)

### isSuperclassOrSame

    public static boolean isSuperclassOrSame(java.lang.String sup,
                                             Type type)

### isSuperclassOrSame

    public static boolean isSuperclassOrSame(Type sup,
                                             Type type)

### isSupertype

    public static boolean isSupertype(Type sup,
                                      Type type)

### isSupertypeOrSame

    public static boolean isSupertypeOrSame(java.lang.Class sup,
                                            Type type)

### isSupertypeOrSame

    public static boolean isSupertypeOrSame(java.lang.String sup,
                                            Type type)

### isSupertypeOrSame

    public static boolean isSupertypeOrSame(Type sup,
                                            Type type)

### isWideningConversion

    public static boolean isWideningConversion(int src,
                                               int dest)

### isWideningConversion

    public static boolean isWideningConversion(Type src,
                                               Type dest)

### membersEqual

    public static boolean membersEqual(Member m1,
                                       Member m2,
                                       boolean ignoreDeclaringType)

### modifiersToString

    public static java.lang.String modifiersToString(int mods)

### overlaps

    public static boolean overlaps(FieldChain a,
                                   int[] aindices,
                                   FieldChain b,
                                   int[] bindices)

### set

    public static void set(java.lang.Object object,
                           Field field,
                           java.lang.Object value)
                    throws java.lang.IllegalAccessException

  Throws:
    `java.lang.IllegalAccessException`

### toString

    public static java.lang.String toString(Field field)

### toString

    public static java.lang.String toString(Type t)

### toType

    public static java.lang.Object toType(java.lang.Object v,
                                          Type t)

Overview | Package | Class | Tree | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD