Get a reference to a method of the specified name with no argument in the indicated class or one of its ancestors. @param clazz target Java class @param methodName method name @return Method object with 'accessible' flag set @throws JsonException if a security violation is encountered
(Class<?> clazz, String methodName)
| 554 | * @throws JsonException if a security violation is encountered |
| 555 | */ |
| 556 | private static @Nullable Method getMethod(Class<?> clazz, String methodName) { |
| 557 | if (Object.class.equals(clazz)) { |
| 558 | return null; |
| 559 | } |
| 560 | |
| 561 | try { |
| 562 | Method method = clazz.getDeclaredMethod(methodName); |
| 563 | method.setAccessible(true); |
| 564 | return method; |
| 565 | } catch (NoSuchMethodException e) { |
| 566 | return getMethod(clazz.getSuperclass(), methodName); |
| 567 | } catch (SecurityException e) { |
| 568 | throw new JsonException( |
| 569 | "Unable to find the method because of a security constraint: " + methodName, e); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | /** |
| 574 | * Convert the specified Java object using the indicated zero-argument method of this object. |
no test coverage detected