In order to support fields of the same name in subclasses we are now prefixing them with name of the class that defines them. To provide convenient way to access them from generated bytecode and also directly from JavaScript, there is a getter/setter function for each field. It starts with _ followed by the field name. If called with a parameter, it sets the field, with a parameter it just returns it.
2 * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
26 package java.lang.reflect;
28 import java.lang.annotation.Annotation;
31 * The AccessibleObject class is the base class for Field, Method and
32 * Constructor objects. It provides the ability to flag a reflected
33 * object as suppressing default Java language access control checks
34 * when it is used. The access checks--for public, default (package)
35 * access, protected, and private members--are performed when Fields,
36 * Methods or Constructors are used to set or get fields, to invoke
37 * methods, or to create and initialize new instances of classes,
40 * <p>Setting the {@code accessible} flag in a reflected object
41 * permits sophisticated applications with sufficient privilege, such
42 * as Java Object Serialization or other persistence mechanisms, to
43 * manipulate objects in a manner that would normally be prohibited.
45 * <p>By default, a reflected object is <em>not</em> accessible.
50 * @see ReflectPermission
54 public class AccessibleObject implements AnnotatedElement {
57 * Convenience method to set the {@code accessible} flag for an
58 * array of objects with a single security check (for efficiency).
60 * <p>First, if there is a security manager, its
61 * {@code checkPermission} method is called with a
62 * {@code ReflectPermission("suppressAccessChecks")} permission.
64 * <p>A {@code SecurityException} is raised if {@code flag} is
65 * {@code true} but accessibility of any of the elements of the input
66 * {@code array} may not be changed (for example, if the element
67 * object is a {@link Constructor} object for the class {@link
68 * java.lang.Class}). In the event of such a SecurityException, the
69 * accessibility of objects is set to {@code flag} for array elements
70 * upto (and excluding) the element for which the exception occurred; the
71 * accessibility of elements beyond (and including) the element for which
72 * the exception occurred is unchanged.
74 * @param array the array of AccessibleObjects
75 * @param flag the new value for the {@code accessible} flag
77 * @throws SecurityException if the request is denied.
78 * @see SecurityManager#checkPermission
79 * @see java.lang.RuntimePermission
81 public static void setAccessible(AccessibleObject[] array, boolean flag)
82 throws SecurityException {
83 throw new SecurityException();
87 * Set the {@code accessible} flag for this object to
88 * the indicated boolean value. A value of {@code true} indicates that
89 * the reflected object should suppress Java language access
90 * checking when it is used. A value of {@code false} indicates
91 * that the reflected object should enforce Java language access checks.
93 * <p>First, if there is a security manager, its
94 * {@code checkPermission} method is called with a
95 * {@code ReflectPermission("suppressAccessChecks")} permission.
97 * <p>A {@code SecurityException} is raised if {@code flag} is
98 * {@code true} but accessibility of this object may not be changed
99 * (for example, if this element object is a {@link Constructor} object for
100 * the class {@link java.lang.Class}).
102 * <p>A {@code SecurityException} is raised if this object is a {@link
103 * java.lang.reflect.Constructor} object for the class
104 * {@code java.lang.Class}, and {@code flag} is true.
106 * @param flag the new value for the {@code accessible} flag
107 * @throws SecurityException if the request is denied.
108 * @see SecurityManager#checkPermission
109 * @see java.lang.RuntimePermission
111 public void setAccessible(boolean flag) throws SecurityException {
112 throw new SecurityException();
116 * Get the value of the {@code accessible} flag for this object.
118 * @return the value of the object's {@code accessible} flag
120 public boolean isAccessible() {
125 * Constructor: only used by the Java Virtual Machine.
127 protected AccessibleObject() {}
129 // Indicates whether language-level access checks are overridden
130 // by this object. Initializes to "false". This field is used by
131 // Field, Method, and Constructor.
133 // NOTE: for security purposes, this field must not be visible
134 // outside this package.
138 * @throws NullPointerException {@inheritDoc}
141 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
142 throw new AssertionError("All subclasses should override this method");
146 * @throws NullPointerException {@inheritDoc}
149 public boolean isAnnotationPresent(
150 Class<? extends Annotation> annotationClass) {
151 return getAnnotation(annotationClass) != null;
157 public Annotation[] getAnnotations() {
158 return getDeclaredAnnotations();
164 public Annotation[] getDeclaredAnnotations() {
165 throw new AssertionError("All subclasses should override this method");