29 import java.util.HashMap;
30 import java.util.Map;
31
32 /** Common utility routines used by both java.lang and
33 java.lang.reflect */
34
35 public class Reflection {
36
37 /** Used to filter out fields and methods from certain classes from public
38 view, where they are sensitive or they may contain VM-internal objects.
39 These Maps are updated very rarely. Rather than synchronize on
40 each access, we use copy-on-write */
41 private static volatile Map<Class<?>,String[]> fieldFilterMap;
42 private static volatile Map<Class<?>,String[]> methodFilterMap;
43
44 static {
45 Map<Class<?>,String[]> map = new HashMap<Class<?>,String[]>();
46 map.put(Reflection.class,
47 new String[] {"fieldFilterMap", "methodFilterMap"});
48 map.put(System.class, new String[] {"security"});
49 fieldFilterMap = map;
50
51 methodFilterMap = new HashMap<>();
52 }
53
54 /** Returns the class of the caller of the method calling this method,
55 ignoring frames associated with java.lang.reflect.Method.invoke()
56 and its implementation. */
57 @CallerSensitive
58 public static native Class<?> getCallerClass();
59
60 /**
61 * @deprecated This method will be removed in JDK 9.
62 * This method is a private JDK API and retained temporarily for
63 * existing code to run until a replacement API is defined.
64 */
65 @Deprecated
66 public static native Class<?> getCallerClass(int depth);
67
68 /** Retrieves the access flags written to the class file. For
|
29 import java.util.HashMap;
30 import java.util.Map;
31
32 /** Common utility routines used by both java.lang and
33 java.lang.reflect */
34
35 public class Reflection {
36
37 /** Used to filter out fields and methods from certain classes from public
38 view, where they are sensitive or they may contain VM-internal objects.
39 These Maps are updated very rarely. Rather than synchronize on
40 each access, we use copy-on-write */
41 private static volatile Map<Class<?>,String[]> fieldFilterMap;
42 private static volatile Map<Class<?>,String[]> methodFilterMap;
43
44 static {
45 Map<Class<?>,String[]> map = new HashMap<Class<?>,String[]>();
46 map.put(Reflection.class,
47 new String[] {"fieldFilterMap", "methodFilterMap"});
48 map.put(System.class, new String[] {"security"});
49 map.put(Class.class, new String[] {"classLoader"});
50 fieldFilterMap = map;
51
52 methodFilterMap = new HashMap<>();
53 }
54
55 /** Returns the class of the caller of the method calling this method,
56 ignoring frames associated with java.lang.reflect.Method.invoke()
57 and its implementation. */
58 @CallerSensitive
59 public static native Class<?> getCallerClass();
60
61 /**
62 * @deprecated This method will be removed in JDK 9.
63 * This method is a private JDK API and retained temporarily for
64 * existing code to run until a replacement API is defined.
65 */
66 @Deprecated
67 public static native Class<?> getCallerClass(int depth);
68
69 /** Retrieves the access flags written to the class file. For
|