144 // method in the VM. (All of this contortion is only necessary
145 // because of the "accessibility" bit in AccessibleObject,
146 // which implicitly requires that new java.lang.reflect
147 // objects be fabricated for each reflective call on Class
148 // objects.)
149 if (this.root != null)
150 throw new IllegalArgumentException("Can not copy a non-root Field");
151
152 Field res = new Field(clazz, name, type, modifiers, slot, signature, annotations);
153 res.root = this;
154 // Might as well eagerly propagate this if already present
155 res.fieldAccessor = fieldAccessor;
156 res.overrideFieldAccessor = overrideFieldAccessor;
157
158 return res;
159 }
160
161 /**
162 * @throws InaccessibleObjectException {@inheritDoc}
163 * @throws SecurityException {@inheritDoc}
164 */
165 @Override
166 @CallerSensitive
167 public void setAccessible(boolean flag) {
168 AccessibleObject.checkPermission();
169 if (flag) checkCanSetAccessible(Reflection.getCallerClass());
170 setAccessible0(flag);
171 }
172
173 @Override
174 void checkCanSetAccessible(Class<?> caller) {
175 checkCanSetAccessible(caller, clazz);
176 }
177
178 /**
179 * Returns the {@code Class} object representing the class or interface
180 * that declares the field represented by this {@code Field} object.
181 */
182 @Override
183 public Class<?> getDeclaringClass() {
|
144 // method in the VM. (All of this contortion is only necessary
145 // because of the "accessibility" bit in AccessibleObject,
146 // which implicitly requires that new java.lang.reflect
147 // objects be fabricated for each reflective call on Class
148 // objects.)
149 if (this.root != null)
150 throw new IllegalArgumentException("Can not copy a non-root Field");
151
152 Field res = new Field(clazz, name, type, modifiers, slot, signature, annotations);
153 res.root = this;
154 // Might as well eagerly propagate this if already present
155 res.fieldAccessor = fieldAccessor;
156 res.overrideFieldAccessor = overrideFieldAccessor;
157
158 return res;
159 }
160
161 /**
162 * @throws InaccessibleObjectException {@inheritDoc}
163 * @throws SecurityException {@inheritDoc}
164 * @since 9
165 */
166 @Override
167 @CallerSensitive
168 public void setAccessible(boolean flag) {
169 AccessibleObject.checkPermission();
170 if (flag) checkCanSetAccessible(Reflection.getCallerClass());
171 setAccessible0(flag);
172 }
173
174 @Override
175 void checkCanSetAccessible(Class<?> caller) {
176 checkCanSetAccessible(caller, clazz);
177 }
178
179 /**
180 * Returns the {@code Class} object representing the class or interface
181 * that declares the field represented by this {@code Field} object.
182 */
183 @Override
184 public Class<?> getDeclaringClass() {
|