Build 1.0_r1(from source)

java.lang.reflect
Class AccessibleObject

java.lang.Object
  extended by java.lang.reflect.AccessibleObject
All Implemented Interfaces:
AnnotatedElement
Direct Known Subclasses:
Constructor, Field, Method

public class AccessibleObject
extends Object
implements 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.

Since:
1.2
See Also:
Field, Constructor, Method, ReflectPermission

Field Summary
(package private)  boolean flag
           
(package private) static Hashtable<String,String> trans
           
 
Constructor Summary
protected AccessibleObject()
          AccessibleObject constructor.
 
Method Summary
(package private)  void appendArrayGenericType(StringBuilder sb, Type[] objs)
          Appends names of the specified array classes to the buffer.
(package private)  void appendArrayType(StringBuilder sb, Class[] objs)
          Appends names of the specified array classes to the buffer.
(package private)  void appendArrayType(StringBuilder sb, Class<?> obj)
          Appends the specified class name to the buffer.
(package private)  void appendGenericType(StringBuilder sb, Type obj)
          Appends the generic type representation to the buffer.
(package private)  void appendSimpleType(StringBuilder sb, Class<?>[] objs)
          Appends names of the specified array classes to the buffer.
<T extends Annotation>
T
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.
(package private) static String getClassSignatureAttribute(Class clazz)
          Retrieve the signature attribute from an arbitrary class.
 Annotation[] getDeclaredAnnotations()
          Gets all Annotations that are explicitly declared by this element (not inherited).
(package private) static org.apache.harmony.kernel.vm.ReflectionAccess getReflectionAccess()
          Gets the unique instance of ReflectionAccessImpl.
(package private)  String getSignature(Class<?> clazz)
          Returns the signature for a class.
(package private)  String getSignatureAttribute()
          Gets the Signature attribute for this instance.
 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.
static void setAccessible(AccessibleObject[] objects, boolean flag)
          Attempts to set the value of the accessible flag for all the objects in the array provided.
 void setAccessible(boolean flag)
          Attempts to set the value of the accessible flag.
(package private)  void setAccessibleNoCheck(boolean flag)
          Sets the accessible flag on this instance without doing any checks.
(package private)  String toString(Class<?>[] types)
          Returns a printable String consisting of the canonical names of the classes contained in an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

flag

boolean flag

trans

static Hashtable<String,String> trans
Constructor Detail

AccessibleObject

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

Method Detail

setAccessible

public static void setAccessible(AccessibleObject[] objects,
                                 boolean flag)
                          throws SecurityException
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
See Also:
setAccessible(boolean), ReflectPermission

isAccessible

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

setAccessible

public void setAccessible(boolean flag)
                   throws SecurityException
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
See Also:
ReflectPermission

setAccessibleNoCheck

void setAccessibleNoCheck(boolean flag)
Sets the accessible flag on this instance without doing any checks.

Parameters:
flag - the new value for the accessible flag

isAnnotationPresent

public boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Queries whether a given Annotation is present on the AccessibleObject.

Specified by:
isAnnotationPresent in interface AnnotatedElement
Parameters:
annotationType - The type of Annotation to look for.
Returns:
true if and only if the given Annotation is present.

getDeclaredAnnotations

public Annotation[] getDeclaredAnnotations()
Description copied from interface: AnnotatedElement
Gets all Annotations that are explicitly declared by this element (not inherited).

Specified by:
getDeclaredAnnotations in interface AnnotatedElement
Returns:
An array of Annotations, which may be empty, but never null.

getAnnotations

public Annotation[] getAnnotations()
Description copied from interface: AnnotatedElement
Gets all Annotations for this element.

Specified by:
getAnnotations in interface AnnotatedElement
Returns:
An array of Annotations, which may be empty, but never null.

getAnnotation

public <T extends Annotation> T getAnnotation(Class<T> annotationType)
Description copied from interface: AnnotatedElement
Gets the Annotation for this element for the annotation type passed, if it exists.

Specified by:
getAnnotation in interface AnnotatedElement
Parameters:
annotationType - The Class instance of the annotation to search for.
Returns:
The Annotation for this element or null.

getSignature

String getSignature(Class<?> clazz)
Returns the signature for a class. This is the kind of signature used internally by the JVM, with one-character codes representing the basic types. It is not suitable for printing.

Parameters:
clazz - The class for which a signature is required.
Returns:
The signature as a string.

toString

String toString(Class<?>[] types)
Returns a printable String consisting of the canonical names of the classes contained in an array. The form is that used in parameter and exception lists, that is, the class or type names are separated by commas.

Parameters:
types - The array of classes.
Returns:
The String of names.

getSignatureAttribute

String getSignatureAttribute()
Gets the Signature attribute for this instance. Returns null if not found.


getClassSignatureAttribute

static String getClassSignatureAttribute(Class clazz)
Retrieve the signature attribute from an arbitrary class. This is the same as Class.getSignatureAttribute(), but it can be used from the java.lang.reflect package.


getReflectionAccess

static org.apache.harmony.kernel.vm.ReflectionAccess getReflectionAccess()
Gets the unique instance of ReflectionAccessImpl.

Returns:
non-null; the unique instance

appendArrayType

void appendArrayType(StringBuilder sb,
                     Class<?> obj)
Appends the specified class name to the buffer. The class may represent a simple type, a reference type or an array type.

Parameters:
sb - buffer
obj - the class which name should be appended to the buffer
Throws:
NullPointerException - if any of the arguments is null

appendArrayType

void appendArrayType(StringBuilder sb,
                     Class[] objs)
Appends names of the specified array classes to the buffer. The array elements may represent a simple type, a reference type or an array type. Output format: java.lang.Object[], java.io.File, void

Parameters:
sb - buffer
objs - array of classes to print the names
Throws:
NullPointerException - if any of the arguments is null

appendArrayGenericType

void appendArrayGenericType(StringBuilder sb,
                            Type[] objs)
Appends names of the specified array classes to the buffer. The array elements may represent a simple type, a reference type or an array type. Output format: java.lang.Object[], java.io.File, void

Parameters:
sb - buffer
objs - array of classes to print the names
Throws:
NullPointerException - if any of the arguments is null

appendGenericType

void appendGenericType(StringBuilder sb,
                       Type obj)
Appends the generic type representation to the buffer.

Parameters:
sb - buffer
obj - the generic type which representation should be appended to the buffer
Throws:
NullPointerException - if any of the arguments is null

appendSimpleType

void appendSimpleType(StringBuilder sb,
                      Class<?>[] objs)
Appends names of the specified array classes to the buffer. The array elements may represent a simple type, a reference type or an array type. In case if the specified array element represents an array type its internal will be appended to the buffer. Output format: [Ljava.lang.Object;, java.io.File, void

Parameters:
sb - buffer
objs - array of classes to print the names
Throws:
NullPointerException - if any of the arguments is null

Build 1.0_r1(from source)

Please submit a feedback, bug or feature