(Class<?> clazz, Class<?> type, String name)
| 1008 | } |
| 1009 | |
| 1010 | public static Field findField(Class<?> clazz, Class<?> type, String name) throws NoSuchFieldException { |
| 1011 | if (clazz == null) { |
| 1012 | throw new NullPointerException("clazz == null"); |
| 1013 | } |
| 1014 | if (name == null) { |
| 1015 | throw new NullPointerException("name == null"); |
| 1016 | } |
| 1017 | Class<?> clz = clazz; |
| 1018 | do { |
| 1019 | for (Field field : clz.getDeclaredFields()) { |
| 1020 | if ((type == null || field.getType().equals(type)) && field.getName().equals(name)) { |
| 1021 | field.setAccessible(true); |
| 1022 | return field; |
| 1023 | } |
| 1024 | } |
| 1025 | } while ((clz = clz.getSuperclass()) != null); |
| 1026 | String errMsg = type == null ? ("field '" + name + "' not found in " + clazz.getName()) |
| 1027 | : ("field '" + name + "' of type " + type.getName() + " not found in " + clazz.getName()); |
| 1028 | throw new NoSuchFieldException(errMsg); |
| 1029 | } |
| 1030 | |
| 1031 | public static Method findMethodByTypes_1(Class<?> clazz, Class returnType, Class... argt) |
| 1032 | throws NoSuchMethodException { |
no test coverage detected