|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.reflect.AccessibleObject
public class AccessibleObject
This class is the superclass of various reflection classes, and allows sufficiently trusted code to bypass normal restrictions to do necessary things like invoke private methods outside of the class during Serialization. If you don't have a good reason to mess with this, don't try. Fortunately, there are adequate security checks before you can set a reflection object as accessible.
Field
,
Constructor
,
Method
,
ReflectPermission
Constructor Summary | |
---|---|
protected |
AccessibleObject()
Only the three reflection classes that extend this can create an accessible object. |
Method Summary | ||
---|---|---|
|
getAnnotation(Class<T> annotationClass)
Returns the element's annotation for the specified annotation type, or null if no such annotation exists. |
|
Annotation[] |
getAnnotations()
Returns all annotations associated with the element. |
|
Annotation[] |
getDeclaredAnnotations()
Returns all annotations directly defined by the element. |
|
boolean |
isAccessible()
Return the accessibility status of this object. |
|
boolean |
isAnnotationPresent(Class<? extends Annotation> annotationClass)
Returns true if an annotation for the specified type is associated with the element. |
|
static void |
setAccessible(AccessibleObject[] array,
boolean flag)
Convenience method to set the flag on a number of objects with a single security check. |
|
void |
setAccessible(boolean flag)
Sets the accessibility flag for this reflection object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected AccessibleObject()
Method Detail |
---|
public boolean isAccessible()
public static void setAccessible(AccessibleObject[] array, boolean flag)
ReflectPermission("suppressAccessChecks")
.It is forbidden to set the accessibility flag to true on any constructor for java.lang.Class. This will result in a SecurityException. If the SecurityException is thrown for any of the passed AccessibleObjects, the accessibility flag will be set on AccessibleObjects in the array prior to the one which resulted in the exception.
array
- the array of accessible objectsflag
- the desired state of accessibility, true to bypass security
NullPointerException
- if array is null
SecurityException
- if the request is deniedSecurityManager.checkPermission(java.security.Permission)
,
RuntimePermission
public void setAccessible(boolean flag)
ReflectPermission("suppressAccessChecks")
.It is forbidden to set the accessibility flag to true on any constructor for java.lang.Class. This will result in a SecurityException.
flag
- the desired state of accessibility, true to bypass security
NullPointerException
- if array is null
SecurityException
- if the request is deniedSecurityManager.checkPermission(java.security.Permission)
,
RuntimePermission
public <T extends Annotation> T getAnnotation(Class<T> annotationClass)
AnnotatedElement
null
if no such annotation exists.
getAnnotation
in interface AnnotatedElement
annotationClass
- the type of annotation to look for.
null
if no such annotation exists.public Annotation[] getAnnotations()
AnnotatedElement
getAnnotations
in interface AnnotatedElement
public Annotation[] getDeclaredAnnotations()
AnnotatedElement
getDeclaredAnnotations
in interface AnnotatedElement
public boolean isAnnotationPresent(Class<? extends Annotation> annotationClass)
AnnotatedElement
isAnnotationPresent
in interface AnnotatedElement
annotationClass
- the type of annotation to look for.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |