159
160 //--------------------------------------------------------------------------
161 //
162 // Routines used by java.lang.reflect
163 //
164 //
165
166 /*
167 * Note: this routine can cause the declaring class for the field
168 * be initialized and therefore must not be called until the
169 * first get/set of this field.
170 * @param field the field
171 * @param override true if caller has overridden accessibility
172 */
173 public FieldAccessor newFieldAccessor(Field field, boolean override) {
174 checkInitted();
175
176 Field root = langReflectAccess.getRoot(field);
177 if (root != null) {
178 // FieldAccessor will use the root unless the modifiers have
179 // been overrridden
180 if (root.getModifiers() == field.getModifiers() || !override) {
181 field = root;
182 }
183 }
184 return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
185 }
186
187 public MethodAccessor newMethodAccessor(Method method) {
188 checkInitted();
189
190 if (Reflection.isCallerSensitive(method)) {
191 Method altMethod = findMethodForReflection(method);
192 if (altMethod != null) {
193 method = altMethod;
194 }
195 }
196
197 // use the root Method that will not cache caller class
198 Method root = langReflectAccess.getRoot(method);
199 if (root != null) {
|
159
160 //--------------------------------------------------------------------------
161 //
162 // Routines used by java.lang.reflect
163 //
164 //
165
166 /*
167 * Note: this routine can cause the declaring class for the field
168 * be initialized and therefore must not be called until the
169 * first get/set of this field.
170 * @param field the field
171 * @param override true if caller has overridden accessibility
172 */
173 public FieldAccessor newFieldAccessor(Field field, boolean override) {
174 checkInitted();
175
176 Field root = langReflectAccess.getRoot(field);
177 if (root != null) {
178 // FieldAccessor will use the root unless the modifiers have
179 // been overridden
180 if (root.getModifiers() == field.getModifiers() || !override) {
181 field = root;
182 }
183 }
184 return UnsafeFieldAccessorFactory.newFieldAccessor(field, override);
185 }
186
187 public MethodAccessor newMethodAccessor(Method method) {
188 checkInitted();
189
190 if (Reflection.isCallerSensitive(method)) {
191 Method altMethod = findMethodForReflection(method);
192 if (altMethod != null) {
193 method = altMethod;
194 }
195 }
196
197 // use the root Method that will not cache caller class
198 Method root = langReflectAccess.getRoot(method);
199 if (root != null) {
|