Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public class

AccessibleObject

extends Object
implements AnnotatedElement
java.lang.Object
   ↳ java.lang.reflect.AccessibleObject
Known Direct Subclasses

Class Overview

AccessibleObject is the superclass of all member reflection classes (Field, Constructor, Method). AccessibleObject provides the ability to toggle a flag controlling access checks for these objects. By default, accessing a member (for example, setting a field or invoking a method) checks the validity of the access (for example, invoking a private method from outside the defining class is prohibited) and throws IllegalAccessException if the operation is not permitted. If the accessible flag is set to true, these checks are omitted. This allows privileged code, such as Java object serialization, object inspectors, and debuggers to have complete access to objects.

Summary

Protected Constructors
AccessibleObject ()
Constructs a new AccessibleObject instance.
Public Methods
<T extends  Annotation > T )">getAnnotation ( Class <T> annotationType)
Returns, for this element, the annotation with the specified type, or null if no annotation with the specified type is present (including inherited annotations).
Annotation[] getAnnotations ()
Returns, for this element, an array containing all annotations (including inherited annotations).
Annotation[] getDeclaredAnnotations ()
Returns, for this element, all annotations that are explicitly declared (not inherited).
boolean isAccessible ()
Indicates whether this object is accessible without access checks being performed.
boolean )">isAnnotationPresent ( Class <? extends  Annotation > annotationType)
Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).
void setAccessible (boolean flag)
Attempts to set the value of the accessible flag.
static void setAccessible ( AccessibleObject[] objects, boolean flag)
Attempts to set the value of the accessible flag for all the objects in the array provided.
[Expand]
Inherited Methods
From class java.lang.Object
From interface java.lang.reflect.AnnotatedElement

Protected Constructors

protected AccessibleObject ()

Added in API level 1

Constructs a new AccessibleObject instance. AccessibleObject instances can only be constructed by the virtual machine.

Public Methods

)">

public T getAnnotation ( Class <T> annotationType)

Added in API level 1

Returns, for this element, the annotation with the specified type, or null if no annotation with the specified type is present (including inherited annotations).

Parameters
annotationType the type of the annotation to search for
Returns
  • the annotation with the specified type or null

public Annotation[] getAnnotations ()

Added in API level 1

Returns, for this element, an array containing all annotations (including inherited annotations). If there are no annotations present, this method returns a zero length array.

Returns
  • an array of all annotations for this element

public Annotation[] getDeclaredAnnotations ()

Added in API level 1

Returns, for this element, all annotations that are explicitly declared (not inherited). If there are no declared annotations present, this method returns a zero length array.

Returns
  • an array of annotations declared for this element

public boolean isAccessible ()

Added in API level 1

Indicates whether this object is accessible without access checks being performed. Returns the accessible flag.

Returns
  • true if this object is accessible without access checks, false otherwise
)">

public boolean isAnnotationPresent ( Class <? extends  Annotation > annotationType)

Added in API level 1

Indicates whether or not this element has an annotation with the specified annotation type (including inherited annotations).

Parameters
annotationType the type of the annotation to search for
Returns
  • true if the annotation exists, false otherwise

public void setAccessible (boolean flag)

Added in API level 1

Attempts to set the value of the accessible flag. Setting this flag to false will enable access checks, setting to true will disable them.

Parameters
flag the new value for the accessible flag

public static void setAccessible ( AccessibleObject[] objects, boolean flag)

Added in API level 1

Attempts to set the value of the accessible flag for all the objects in the array provided. Setting this flag to false will enable access checks, setting to true will disable them.

Parameters
objects the accessible objects
flag the new value for the accessible flag