Package io.microsphere.reflect
Class AccessibleObjectUtils
- java.lang.Object
-
- io.microsphere.reflect.AccessibleObjectUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleancanAccess(java.lang.Object object, java.lang.reflect.AccessibleObject accessibleObject)Test if the caller can access this reflected object.static booleantrySetAccessible(java.lang.reflect.AccessibleObject accessibleObject)Try to set theAccessibleObjectaccessible.
-
-
-
Method Detail
-
trySetAccessible
public static boolean trySetAccessible(java.lang.reflect.AccessibleObject accessibleObject)
Try to set theAccessibleObjectaccessible.If JDK >=9 ,
AccessibleObject#trySetAccessible()method will be invoked, orAccessibleObject.setAccessible(boolean)method will be invoked ifAccessibleObject.isAccessible()isfalse.- Parameters:
accessibleObject- theAccessibleObjectinstance- 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 givenobjwith the reflected object. For instance methods or fields then theobjargument must be an instance of thedeclaring class. For static members and constructors thenobjmust benull.- Parameters:
object- an instance object of the declaring class of this reflected object if it is an instance method or field- Returns:
trueif the caller can access this reflected object.
-
-