Android
java.lang.reflect
public class

java.lang.reflect.AccessibleObject

java.lang.Object
java.lang.reflect.AccessibleObject AnnotatedElement

This class must be implemented by the VM vendor. This class is the superclass of all member reflect classes (Field, Constructor, Method). AccessibleObject provides the ability to toggle 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 applications such as Java Object Serialization, inspectors, and debuggers to have complete access to objects.

Known Direct Subclasses

Summary

Protected Constructors

            AccessibleObject()
AccessibleObject constructor.

Public Methods

        <T extends Annotation getAnnotation(Class<T> annotationType)
Gets the Annotation for this element for the annotation type passed, if it exists.
          Annotation[]  getAnnotations()
Gets all Annotations for this element.
          Annotation[]  getDeclaredAnnotations()
Gets all Annotations that are explicitly declared by this element (not inherited).
          boolean  isAccessible()
Returns the value of the accessible flag.
          boolean  isAnnotationPresent(Class<? extends Annotation> annotationType)
Queries whether a given Annotation is present on the AccessibleObject.
          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.
Methods inherited from class java.lang.Object
Methods inherited from interface java.lang.reflect.AnnotatedElement

Details

Protected Constructors

protected AccessibleObject()

AccessibleObject constructor. AccessibleObjects can only be created by the Virtual Machine.

Public Methods

public T getAnnotation(Class<T> annotationType)

Gets the Annotation for this element for the annotation type passed, if it exists.

public Annotation[] getAnnotations()

Gets all Annotations for this element.

public Annotation[] getDeclaredAnnotations()

Gets all Annotations that are explicitly declared by this element (not inherited).

public boolean isAccessible()

Returns the value of the accessible flag. This is false if access checks are performed, true if they are skipped.

Returns

  • the value of the accessible flag

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

Queries whether a given Annotation is present on the AccessibleObject.

Parameters

annotationType The type of Annotation to look for.

Returns

  • true if and only if the given Annotation is present.

public void setAccessible(boolean flag)

Attempts to set the value of the accessible flag. Setting this flag to false will enable access checks, setting to true will disable them. If there is a security manager, checkPermission is called with a ReflectPermission("suppressAccessChecks").

Parameters

flag the new value for the accessible flag

Throws

SecurityException if the request is denied

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

Attempts to set the value of the accessible flag for all the objects in the array provided. Only one security check is performed. Setting this flag to false will enable access checks, setting to true will disable them. If there is a security manager, checkPermission is called with a ReflectPermission("suppressAccessChecks").

Parameters

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

Throws

SecurityException if the request is denied
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56