java.lang.Object
de.grogra.reflect.Reflection
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
canLoad
(ClassLoader loader, Class cls) static boolean
static boolean
static boolean
static Member
static Field
findFieldInClasses
(Type type, String nameOrDescriptor) static Type
static Method
findMethodInClasses
(Type type, String name) static Method
findMethodWithPrefixInTypes
(Type type, String descriptorPrefix, boolean includeInterfaces, boolean publicOnly) static Object
static Type<?>
getBinaryType
(Type<?> type) static <T extends Annotation>
Annotation<T>getDeclaredAnnotation
(Member member, Class<T> cls) static Field
getDeclaredField
(Type type, String nameOrDescriptor) static Field[]
getDeclaredFields
(Type type) static Type[]
getDeclaredInterfaces
(Type type) static Method
getDeclaredMethod
(Type type, String nameOrDescriptor) static Method
getDeclaredMethod
(Type type, String nameOrDescriptor, Boolean requiresPublic) static Method[]
getDeclaredMethods
(Type type) static Type
getDeclaredType
(Type type, String nameOrDescriptor) static Type[]
getDeclaredTypes
(Type type) static Method
getDefaultConstructor
(Type type) static String
static String
getDescriptor
(Type[] types) static int
getDimensionCount
(Type type) static Method
getElementMethod
(Type type, String element) static Type
getEnclosingType
(Type inner, Member member) Returns the innermost of the enclosing types ofinner
of whichmember
is a member.static Type[]
getExceptions
(Method method) static String
getFieldDescriptor
(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 giventype
within the Java virtual machine.static int
getJVMStackSize
(Type[] types) static int
getJVMTypeId
(Type type) static String
getMethodDescriptor
(String name, Type returnType, Type[] parameterTypes) static Method
getMostSpecificPublicConstructor
(Type type, Object value) static Type
getParameterType
(Signature m, int index, boolean varArity) static Type[]
static Type
getPublicType
(Type[] types) static String
getSyntheticName
(Member[] members, String name) static Type
getTopLevelType
(Type type) static Type
getType
(int typeId) static Type
static final Type
static Type
getType
(String type, ClassLoader loader) static String
getTypeName
(int typeId) static 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 Class
getWrapperClass
(int typeId) static boolean
hasCategory2
(int typeId) static boolean
static boolean
incompatibleReturnTypesExist
(Type t1, Type t2) static boolean
isAbstract
(Member m) static boolean
isAccessible
(Member m, Type instance, Type scope) Determines if memberm
is accessible oninstance
in the contextscope
.static boolean
static boolean
static boolean
isAssignableFrom
(Type target, Type source) static boolean
isCastableFrom
(Type target, Type source) static boolean
Returns true if the method m is a constructor, otherwise returns false.static boolean
static boolean
static boolean
isIntegral
(Type type) static boolean
isInterface
(Type type) static boolean
static boolean
Returnstrue
iffmember
is a member oftype
.static boolean
isMoreVisible
(int mods1, int mods2) static boolean
isPrimitive
(Type type) static boolean
isPrimitiveOrString
(Type type) static boolean
isPrimitiveOrVoid
(Type type) static boolean
static boolean
static boolean
static boolean
static boolean
isSuperclassOrSame
(Type sup, Type type) static boolean
isSuperclassOrSame
(Class sup, Type type) static boolean
isSuperclassOrSame
(String sup, Type type) static boolean
isSupertype
(Type sup, Type type) static boolean
isSupertypeOrSame
(Type sup, Type type) static boolean
isSupertypeOrSame
(Class sup, Type type) static boolean
isSupertypeOrSame
(String 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 String
modifiersToString
(int mods) static boolean
overlaps
(FieldChain a, int[] aindices, FieldChain b, int[] bindices) static void
static String
static String
static Object
-
Method Details
-
getJVMTypeId
-
getJVMPrefix
public static char getJVMPrefix(int typeId) -
getJVMPrefix
-
getJVMStackSize
Returns the number of stack elements which are needed for the storage of values of the giventype
within the Java virtual machine.- Parameters:
type
- a type- Returns:
- the required size in terms of stack elements
-
getJVMStackSize
-
getDimensionCount
-
getDeclaredFields
-
getDeclaredMethods
-
getDeclaredInterfaces
-
getDeclaredTypes
-
getExceptions
-
getParameterTypes
-
getParameterType
-
membersEqual
-
find
-
getSyntheticName
-
modifiersToString
-
isStatic
-
isFinal
-
isPrivate
-
isProtected
-
isPublic
-
hasDefaultAccess
-
isAbstract
-
isInner
-
isMoreVisible
public static boolean isMoreVisible(int mods1, int mods2) -
equal
-
getDescription
-
getMethodDescriptor
-
getFieldDescriptor
-
get
- Throws:
IllegalAccessException
-
set
- Throws:
IllegalAccessException
-
toString
-
getDescriptor
-
getTopLevelType
-
isMember
Returnstrue
iffmember
is a member oftype
. This is the case ifmember
is declared intype
or one of its supertypes.- Parameters:
member
- a membertype
- a type- Returns:
true
iffmember
is a member oftype
-
getEnclosingType
Returns the innermost of the enclosing types ofinner
of whichmember
is a member. May beinner
itself. Returnsnull
if no such type can be found.- Parameters:
inner
- a typemember
- a member- Returns:
- innermost enclosing type of
inner
which hasmember
as member
-
getDeclaredType
-
overlaps
-
getDeclaredField
-
getDeclaredMethod
-
getDeclaredMethod
-
getElementMethod
-
getMostSpecificPublicConstructor
-
getDefaultConstructor
-
findMethodInClasses
-
findMethodWithPrefixInTypes
-
findFieldInClasses
-
getDeclaredAnnotation
public static <T extends Annotation> Annotation<T> getDeclaredAnnotation(Member member, Class<T> cls) -
findFirst
-
getType
-
getType
-
getTypeName
-
getTypeSuffix
-
isSuperclassOrSame
-
isSuperclassOrSame
-
isSupertypeOrSame
-
isSupertypeOrSame
-
isSuperclassOrSame
-
isSupertypeOrSame
-
isSupertype
-
isAssignableFrom
-
incompatibleReturnTypesExist
-
getBinaryType
-
isCastableFrom
-
equal
-
equal
-
toString
-
isWideningConversion
public static boolean isWideningConversion(int src, int dest) -
isWideningConversion
-
toType
-
getPublicType
-
getType
-
getType
-
isIntegral
-
isPrimitive
-
isInterface
-
isArray
-
isCtor
Returns true if the method m is a constructor, otherwise returns false.- Parameters:
m
- a method- Returns:
true
iffm
is a constructor
-
isPrimitiveOrVoid
-
isPrimitiveOrString
-
hasCategory2
public static boolean hasCategory2(int typeId) -
getWrapperClass
-
getUnwrappedType
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
-
isAccessible
Determines if memberm
is accessible oninstance
in the contextscope
.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 ofm
occurs.
NOTE: This method does not check if the declaring type ofm
is accessible.- Parameters:
m
- a memberinstance
- instance for instance methods and fieldsscope
- type in whose declarationm
is accessed- Returns:
true
iff the access is permitted
-
canLoad
-
isAncestorOrSame
-
isInvalid
-