49 fieldFilterMap = map; |
49 fieldFilterMap = map; |
50 |
50 |
51 methodFilterMap = new HashMap<>(); |
51 methodFilterMap = new HashMap<>(); |
52 } |
52 } |
53 |
53 |
54 /** Returns the class of the method <code>realFramesToSkip</code> |
54 /** Returns the class of the caller of the method calling this method, |
55 frames up the stack (zero-based), ignoring frames associated |
55 ignoring frames associated with java.lang.reflect.Method.invoke() |
56 with java.lang.reflect.Method.invoke() and its implementation. |
56 and its implementation. */ |
57 The first frame is that associated with this method, so |
57 @CallerSensitive |
58 <code>getCallerClass(0)</code> returns the Class object for |
58 public static native Class<?> getCallerClass(); |
59 sun.reflect.Reflection. Frames associated with |
|
60 java.lang.reflect.Method.invoke() and its implementation are |
|
61 completely ignored and do not count toward the number of "real" |
|
62 frames skipped. */ |
|
63 public static native Class<?> getCallerClass(int realFramesToSkip); |
|
64 |
59 |
65 /** Retrieves the access flags written to the class file. For |
60 /** Retrieves the access flags written to the class file. For |
66 inner classes these flags may differ from those returned by |
61 inner classes these flags may differ from those returned by |
67 Class.getModifiers(), which searches the InnerClasses |
62 Class.getModifiers(), which searches the InnerClasses |
68 attribute to find the source-level access flags. This is used |
63 attribute to find the source-level access flags. This is used |
319 newMembers[destIdx++] = member; |
314 newMembers[destIdx++] = member; |
320 } |
315 } |
321 } |
316 } |
322 return newMembers; |
317 return newMembers; |
323 } |
318 } |
|
319 |
|
320 /** |
|
321 * Tests if the given method is caller-sensitive and the declaring class |
|
322 * is defined by either the bootstrap class loader or extension class loader. |
|
323 */ |
|
324 public static boolean isCallerSensitive(Method m) { |
|
325 final ClassLoader loader = m.getDeclaringClass().getClassLoader(); |
|
326 if (sun.misc.VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) { |
|
327 return m.isAnnotationPresent(CallerSensitive.class); |
|
328 } |
|
329 return false; |
|
330 } |
|
331 |
|
332 private static boolean isExtClassLoader(ClassLoader loader) { |
|
333 ClassLoader cl = ClassLoader.getSystemClassLoader(); |
|
334 while (cl != null) { |
|
335 if (cl.getParent() == null && cl == loader) { |
|
336 return true; |
|
337 } |
|
338 cl = cl.getParent(); |
|
339 } |
|
340 return false; |
|
341 } |
324 } |
342 } |