(Class clas, String fieldName)
| 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 | /** |
no test coverage detected