Package org.apache.commons.lang3.reflect
Class MemberUtils
- java.lang.Object
-
- org.apache.commons.lang3.reflect.MemberUtils
-
abstract class MemberUtils extends Object
Contains common code for working withMethods/Constructors, extracted and refactored fromMethodUtilswhen it was imported from Commons BeanUtils.- Since:
- 2.5
-
-
Constructor Summary
Constructors Constructor Description MemberUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description (package private) static intcompareConstructorFit(Constructor<?> left, Constructor<?> right, Class<?>[] actual)Compares the relative fitness of two Constructors in terms of how well they match a set of runtime parameter types, such that a list ordered by the results of the comparison would return the best match first (least).(package private) static intcompareMethodFit(Method left, Method right, Class<?>[] actual)Compares the relative fitness of two Methods in terms of how well they match a set of runtime parameter types, such that a list ordered by the results of the comparison would return the best match first (least).(package private) static booleanisAccessible(Member m)Returns whether aMemberis accessible.(package private) static booleanisMatchingConstructor(Constructor<?> method, Class<?>[] parameterTypes)(package private) static booleanisMatchingMethod(Method method, Class<?>[] parameterTypes)(package private) static booleanisPackageAccess(int modifiers)Returns whether a given set of modifiers implies package access.(package private) static booleansetAccessibleWorkaround(AccessibleObject o)XXX Default access superclass workaround.
-
-
-
Method Detail
-
setAccessibleWorkaround
static boolean setAccessibleWorkaround(AccessibleObject o)
XXX Default access superclass workaround. When apublicclass has a default access superclass withpublicmembers, these members are accessible. Calling them from compiled code works fine. Unfortunately, on some JVMs, using reflection to invoke these members seems to (wrongly) prevent access even when the modifier ispublic. CallingsetAccessible(true)solves the problem but will only work from sufficiently privileged code. Better workarounds would be gratefully accepted.- Parameters:
o- the AccessibleObject to set as accessible- Returns:
- a boolean indicating whether the accessibility of the object was set to true.
-
isPackageAccess
static boolean isPackageAccess(int modifiers)
Returns whether a given set of modifiers implies package access.- Parameters:
modifiers- to test- Returns:
trueunlesspackage/protected/privatemodifier detected
-
isAccessible
static boolean isAccessible(Member m)
Returns whether aMemberis accessible.- Parameters:
m- Member to check- Returns:
trueifmis accessible
-
compareConstructorFit
static int compareConstructorFit(Constructor<?> left, Constructor<?> right, Class<?>[] actual)
Compares the relative fitness of two Constructors in terms of how well they match a set of runtime parameter types, such that a list ordered by the results of the comparison would return the best match first (least).- Parameters:
left- the "left" Constructorright- the "right" Constructoractual- the runtime parameter types to match againstleft/right- Returns:
- int consistent with
comparesemantics - Since:
- 3.5
-
compareMethodFit
static int compareMethodFit(Method left, Method right, Class<?>[] actual)
Compares the relative fitness of two Methods in terms of how well they match a set of runtime parameter types, such that a list ordered by the results of the comparison would return the best match first (least).- Parameters:
left- the "left" Methodright- the "right" Methodactual- the runtime parameter types to match againstleft/right- Returns:
- int consistent with
comparesemantics - Since:
- 3.5
-
isMatchingConstructor
static boolean isMatchingConstructor(Constructor<?> method, Class<?>[] parameterTypes)
-
-