Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
java.lang.reflect.AccessibleObject
Field
, Constructor
, Method
, ReflectPermission
Constructor Summary | |
|
Method Summary | |
|
|
Annotation[] |
|
Annotation[] |
|
boolean |
|
boolean |
|
void |
|
static void |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
protected AccessibleObject()
Only the three reflection classes that extend this can create an accessible object. This is not serializable for security reasons.
publicextends Annotation> T getAnnotation (ClassannotationClass)
Returns the element's annotation for the specified annotation type, ornull
if no such annotation exists.This method must be overridden by subclasses to provide appropriate behaviour.
- Specified by:
- extends Annotation> T getAnnotation in interface AnnotatedElement
- Parameters:
annotationClass
- the type of annotation to look for.
- Returns:
- this element's annotation for the specified type, or
null
if no such annotation exists.
- Throws:
NullPointerException
- if the annotation class isnull
.
public Annotation[] getAnnotations()
Returns all annotations associated with the element. If there are no annotations associated with the element, then a zero-length array will be returned. The returned array may be modified by the client code, but this will have no effect on the annotation content of the element, and hence no effect on the return value of this method for future callers.
- Specified by:
- getAnnotations in interface AnnotatedElement
- Returns:
- this element's annotations.
public Annotation[] getDeclaredAnnotations()
Returns all annotations directly defined by the element. If there are no annotations directly associated with the element, then a zero-length array will be returned. The returned array may be modified by the client code, but this will have no effect on the annotation content of this class, and hence no effect on the return value of this method for future callers.This method must be overridden by subclasses to provide appropriate behaviour.
- Specified by:
- getDeclaredAnnotations in interface AnnotatedElement
- Returns:
- the annotations directly defined by the element.
- Since:
- 1.5
public boolean isAccessible()
Return the accessibility status of this object.
- Returns:
- true if this object bypasses security checks
public boolean isAnnotationPresent(Annotation> annotationClass)
Returns true if an annotation for the specified type is associated with the element. This is primarily a short-hand for using marker annotations.
- Specified by:
- isAnnotationPresent in interface AnnotatedElement
- Parameters:
annotationClass
- the type of annotation to look for.
- Returns:
- true if an annotation exists for the specified type.
- Since:
- 1.5
public void setAccessible(boolean flag)
Sets the accessibility flag for this reflection object. If a security manager exists, it is checked forReflectPermission("suppressAccessChecks")
.It is forbidden to set the accessibility flag to true on any constructor for java.lang.Class. This will result in a SecurityException.
- Parameters:
flag
- the desired state of accessibility, true to bypass security
- Throws:
NullPointerException
- if array is nullSecurityException
- if the request is denied
public static void setAccessible(AccessibleObject[] array, boolean flag)
Convenience method to set the flag on a number of objects with a single security check. If a security manager exists, it is checked forReflectPermission("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.
- Parameters:
array
- the array of accessible objectsflag
- the desired state of accessibility, true to bypass security
- Throws:
NullPointerException
- if array is nullSecurityException
- if the request is denied