MCPcopy Index your code
hub / github.com/beanshell/beanshell / findAccessibleField

Method findAccessibleField

src/bsh/Reflect.java:346–372  ·  view source on GitHub ↗
(Class clas, String fieldName)

Source from the content-addressed store, hash-verified

344 exceptions during the search.
345 */
346 private static Field findAccessibleField(Class clas, String fieldName) throws UtilEvalError, NoSuchFieldException {
347 // Quick check catches public fields include those in interfaces
348 try {
349 return clas.getField(fieldName);
350 } catch (NoSuchFieldException e) {
351 // ignore
352 }
353 // try hidden fields (protected, private, package protected)
354 if (Capabilities.haveAccessibility()) {
355 try {
356 while (clas != null) {
357 final Field[] declaredFields = clas.getDeclaredFields();
358 for (int i = 0; i < declaredFields.length; i++) {
359 Field field = declaredFields[i];
360 if (field.getName().equals(fieldName)) {
361 field.setAccessible(true);
362 return field;
363 }
364 }
365 clas = clas.getSuperclass();
366 }
367 } catch (SecurityException e) {
368 // ignore -> NoSuchFieldException
369 }
370 }
371 throw new NoSuchFieldException(fieldName);
372 }
373
374
375 /**

Callers 1

Calls 4

haveAccessibilityMethod · 0.95
setAccessibleMethod · 0.80
equalsMethod · 0.45
getNameMethod · 0.45

Tested by

no test coverage detected