Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

AccessibleObject

Synopsis

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.

java.lang.reflect.AccessibleObject

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> ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page