java.lang.Object
de.grogra.reflect.Reflection
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleancanLoad(ClassLoader loader, Class cls) static booleanstatic booleanstatic booleanstatic Memberstatic FieldfindFieldInClasses(Type type, String nameOrDescriptor) static Typestatic MethodfindMethodInClasses(Type type, String name) static MethodfindMethodWithPrefixInTypes(Type type, String descriptorPrefix, boolean includeInterfaces, boolean publicOnly) static Objectstatic Type<?> getBinaryType(Type<?> type) static <T extends Annotation>
Annotation<T> getDeclaredAnnotation(Member member, Class<T> cls) static FieldgetDeclaredField(Type type, String nameOrDescriptor) static Field[]getDeclaredFields(Type type) static Type[]getDeclaredInterfaces(Type type) static MethodgetDeclaredMethod(Type type, String nameOrDescriptor) static MethodgetDeclaredMethod(Type type, String nameOrDescriptor, Boolean requiresPublic) static Method[]getDeclaredMethods(Type type) static TypegetDeclaredType(Type type, String nameOrDescriptor) static Type[]getDeclaredTypes(Type type) static MethodgetDefaultConstructor(Type type) static Stringstatic StringgetDescriptor(Type[] types) static intgetDimensionCount(Type type) static MethodgetElementMethod(Type type, String element) static TypegetEnclosingType(Type inner, Member member) Returns the innermost of the enclosing types ofinnerof whichmemberis a member.static Type[]getExceptions(Method method) static StringgetFieldDescriptor(String name, Type type) static chargetJVMPrefix(int typeId) static chargetJVMPrefix(Type type) static intgetJVMStackSize(Type type) Returns the number of stack elements which are needed for the storage of values of the giventypewithin the Java virtual machine.static intgetJVMStackSize(Type[] types) static intgetJVMTypeId(Type type) static StringgetMethodDescriptor(String name, Type returnType, Type[] parameterTypes) static MethodgetMostSpecificPublicConstructor(Type type, Object value) static TypegetParameterType(Signature m, int index, boolean varArity) static Type[]static TypegetPublicType(Type[] types) static StringgetSyntheticName(Member[] members, String name) static TypegetTopLevelType(Type type) static TypegetType(int typeId) static Typestatic final Typestatic TypegetType(String type, ClassLoader loader) static StringgetTypeName(int typeId) static StringgetTypeSuffix(int typeId) static TypegetUnwrappedType(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 ClassgetWrapperClass(int typeId) static booleanhasCategory2(int typeId) static booleanstatic booleanincompatibleReturnTypesExist(Type t1, Type t2) static booleanisAbstract(Member m) static booleanisAccessible(Member m, Type instance, Type scope) Determines if membermis accessible oninstancein the contextscope.static booleanstatic booleanstatic booleanisAssignableFrom(Type target, Type source) static booleanisCastableFrom(Type target, Type source) static booleanReturns true if the method m is a constructor, otherwise returns false.static booleanstatic booleanstatic booleanisIntegral(Type type) static booleanisInterface(Type type) static booleanstatic booleanReturnstrueiffmemberis a member oftype.static booleanisMoreVisible(int mods1, int mods2) static booleanisPrimitive(Type type) static booleanisPrimitiveOrString(Type type) static booleanisPrimitiveOrVoid(Type type) static booleanstatic booleanstatic booleanstatic booleanstatic booleanisSuperclassOrSame(Type sup, Type type) static booleanisSuperclassOrSame(Class sup, Type type) static booleanisSuperclassOrSame(String sup, Type type) static booleanisSupertype(Type sup, Type type) static booleanisSupertypeOrSame(Type sup, Type type) static booleanisSupertypeOrSame(Class sup, Type type) static booleanisSupertypeOrSame(String sup, Type type) static booleanisWideningConversion(int src, int dest) static booleanisWideningConversion(Type src, Type dest) static booleanmembersEqual(Member m1, Member m2, boolean ignoreDeclaringType) static StringmodifiersToString(int mods) static booleanoverlaps(FieldChain a, int[] aindices, FieldChain b, int[] bindices) static voidstatic Stringstatic Stringstatic 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 giventypewithin 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
Returnstrueiffmemberis a member oftype. This is the case ifmemberis declared intypeor one of its supertypes.- Parameters:
member- a membertype- a type- Returns:
trueiffmemberis a member oftype
-
getEnclosingType
Returns the innermost of the enclosing types ofinnerof whichmemberis a member. May beinneritself. Returnsnullif no such type can be found.- Parameters:
inner- a typemember- a member- Returns:
- innermost enclosing type of
innerwhich hasmemberas 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:
trueiffmis 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 membermis accessible oninstancein the contextscope.instanceis only needed for instance methods and fields and denotes the instance on which these members are accessed.scopedefines the type in whose declaration the access ofmoccurs.
NOTE: This method does not check if the declaring type ofmis accessible.- Parameters:
m- a memberinstance- instance for instance methods and fieldsscope- type in whose declarationmis accessed- Returns:
trueiff the access is permitted
-
canLoad
-
isAncestorOrSame
-
isInvalid
-