Finds a public, protected or private method by name and parameter types. @param clazz class to search for the method @param name method name @param types method parameters @return method, or null if the method is not found
(final Class<?> clazz, final String name, final Class<?>... types)
| 139 | * @return method, or {@code null} if the method is not found |
| 140 | */ |
| 141 | public static Method method(final Class<?> clazz, final String name, final Class<?>... types) { |
| 142 | if(clazz == null) return null; |
| 143 | Method m = null; |
| 144 | try { |
| 145 | try { |
| 146 | m = clazz.getMethod(name, types); |
| 147 | } catch(final Throwable ex) { |
| 148 | Util.debug(ex); |
| 149 | m = clazz.getDeclaredMethod(name, types); |
| 150 | m.setAccessible(true); |
| 151 | } |
| 152 | } catch(final Throwable ex) { |
| 153 | Util.debug(ex); |
| 154 | } |
| 155 | return m; |
| 156 | } |
| 157 | |
| 158 | /** |
| 159 | * Returns a class instance. |