< prev index next >
src/java.base/share/classes/java/security/AccessController.java
Print this page
rev 53030 : imported patch 8214583
@@ -708,10 +708,17 @@
}
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,19 +739,23 @@
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);
- Reference.reachabilityFence(action);
return result;
}
/**
* Execute the action as privileged.
@@ -759,19 +770,23 @@
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);
- Reference.reachabilityFence(action);
return result;
}
/**
< prev index next >