Team LiB
Previous Section Next Section

AccessibleObjectjava.lang.reflect

Java 1.2

This class is the superclass of the Method, Constructor, and Field classes; its methods provide a mechanism for trusted applications to work with private, protected, and default visibility members that would otherwise not be accessible through the Reflection API. This class is new as of Java 1.2; in Java 1.1, the Method, Constructor, and Field classes extended Object directly.

To use the java.lang.reflect package to access a member to which your code would not normally have access, pass TRue to the setAccessible( ) method. If your code has an appropriate ReflectPermission (such as "suppressAccessChecks"), this allows access to the member as if it were declared public. The static version of setAccessible( ) is a convenience method that sets the accessible flag for an array of members but performs only a single security check.

Figure 10-91. java.lang.reflect.AccessibleObject


public class AccessibleObject implements AnnotatedElement {
// Protected Constructors
     protected AccessibleObject( );  
// Public Class Methods
     public static void setAccessible(AccessibleObject[ ] array, boolean flag) 
     throws SecurityException;  
// Public Instance Methods
     public boolean isAccessible( );  
     public void setAccessible(boolean flag) throws SecurityException;  
// Methods Implementing AnnotatedElement
5.0  public <T extends java.lang.annotation.Annotation> T getAnnotation(Class<T> 
annotationClass);  
5.0  public java.lang.annotation.Annotation[ ] getAnnotations( );  
5.0  public java.lang.annotation.Annotation[ ] getDeclaredAnnotations( );  
5.0  public boolean isAnnotationPresent(Class<? extends java.lang.annotation.
Annotation> annotationClass);  
}

Subclasses

Constructor, Field, Method

    Team LiB
    Previous Section Next Section