Package io.microsphere.reflect
Class AccessibleObjectUtils
- java.lang.Object
-
- io.microsphere.util.BaseUtils
-
- io.microsphere.reflect.AccessibleObjectUtils
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
INACCESSIBLE_OBJECT_EXCEPTION_CLASS_NAME
The class name of java.lang.reflect.InaccessibleObject since JDK 9
-
Constructor Summary
Constructors Constructor Description AccessibleObjectUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
canAccess(java.lang.Object object, java.lang.reflect.AccessibleObject accessibleObject)
Test if the caller can access this reflected object.static boolean
trySetAccessible(java.lang.reflect.AccessibleObject accessibleObject)
Try to set theAccessibleObject
accessible.
-
-
-
Field Detail
-
INACCESSIBLE_OBJECT_EXCEPTION_CLASS_NAME
public static final java.lang.String INACCESSIBLE_OBJECT_EXCEPTION_CLASS_NAME
The class name of java.lang.reflect.InaccessibleObject since JDK 9- See Also:
- Constant Field Values
-
-
Method Detail
-
trySetAccessible
public static boolean trySetAccessible(java.lang.reflect.AccessibleObject accessibleObject)
Try to set theAccessibleObject
accessible.If JDK >=9 ,
AccessibleObject#trySetAccessible()
method will be invoked, orAccessibleObject.setAccessible(boolean)
method will be invoked ifAccessibleObject.isAccessible()
isfalse
.- Parameters:
accessibleObject
- theAccessibleObject
instance- Returns:
- See Also:
AccessibleObject#trySetAccessible()
,AccessibleObject.setAccessible(boolean)
,AccessibleObject.isAccessible()
-
canAccess
public static boolean canAccess(java.lang.Object object, java.lang.reflect.AccessibleObject accessibleObject)
Test if the caller can access this reflected object. If this reflected object corresponds to an instance method or field then this method tests if the caller can access the givenobj
with the reflected object. For instance methods or fields then theobj
argument must be an instance of thedeclaring class
. For static members and constructors thenobj
must benull
.- Parameters:
object
- an instance object of the declaring class of this reflected object if it is an instance method or field- Returns:
true
if the caller can access this reflected object.
-
-