1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.buildcache.hash;
20
21 import java.lang.reflect.Field;
22 import java.lang.reflect.Method;
23
24
25
26
27 class ReflectionUtils {
28
29 static Method getMethod(String className, String methodName, Class<?>... parameterTypes) {
30 try {
31 final Method method = Class.forName(className).getMethod(methodName, parameterTypes);
32 method.setAccessible(true);
33 return method;
34 } catch (Exception ignore) {
35 return null;
36 }
37 }
38
39 static Object getField(String className, String fieldName) {
40 try {
41 final Field field = Class.forName(className).getDeclaredField(fieldName);
42 field.setAccessible(true);
43 return field.get(null);
44 } catch (Exception ignore) {
45 return null;
46 }
47 }
48
49 private ReflectionUtils() {}
50 }