< prev index next >
src/java.base/share/classes/java/security/AccessController.java
Print this page
rev 53030 : imported patch 8214583
*** 708,717 ****
--- 708,724 ----
}
return context;
}
/**
+ * The value needs to be physically located in the frame, so that it
+ * can be found by a stack walk.
+ */
+ @Hidden
+ private static native void ensureMaterializedForStackWalk(Object o);
+
+ /**
* Sanity check that the caller context is indeed privileged.
*
* Used by executePrivileged to make sure the frame is properly
* recognized by the VM.
*/
*** 732,750 ****
private static <T> T
executePrivileged(PrivilegedAction<T> action,
AccessControlContext context,
Class<?> caller)
{
assert isPrivileged(); // sanity check invariant
T result = action.run();
assert isPrivileged(); // sanity check invariant
// Keep these alive across the run() call so they can be
// retrieved by getStackAccessControlContext().
Reference.reachabilityFence(context);
Reference.reachabilityFence(caller);
- Reference.reachabilityFence(action);
return result;
}
/**
* Execute the action as privileged.
--- 739,761 ----
private static <T> T
executePrivileged(PrivilegedAction<T> action,
AccessControlContext context,
Class<?> caller)
{
+ // Ensure context has a physical value in the frame
+ if (context != null) {
+ ensureMaterializedForStackWalk(context);
+ }
+
assert isPrivileged(); // sanity check invariant
T result = action.run();
assert isPrivileged(); // sanity check invariant
// Keep these alive across the run() call so they can be
// retrieved by getStackAccessControlContext().
Reference.reachabilityFence(context);
Reference.reachabilityFence(caller);
return result;
}
/**
* Execute the action as privileged.
*** 759,777 ****
executePrivileged(PrivilegedExceptionAction<T> action,
AccessControlContext context,
Class<?> caller)
throws Exception
{
assert isPrivileged(); // sanity check invariant
T result = action.run();
assert isPrivileged(); // sanity check invariant
// Keep these alive across the run() call so they can be
// retrieved by getStackAccessControlContext().
Reference.reachabilityFence(context);
Reference.reachabilityFence(caller);
- Reference.reachabilityFence(action);
return result;
}
/**
--- 770,792 ----
executePrivileged(PrivilegedExceptionAction<T> action,
AccessControlContext context,
Class<?> caller)
throws Exception
{
+ // Ensure context has a physical value in the frame
+ if (context != null) {
+ ensureMaterializedForStackWalk(context);
+ }
+
assert isPrivileged(); // sanity check invariant
T result = action.run();
assert isPrivileged(); // sanity check invariant
// Keep these alive across the run() call so they can be
// retrieved by getStackAccessControlContext().
Reference.reachabilityFence(context);
Reference.reachabilityFence(caller);
return result;
}
/**
< prev index next >