8036841: Reuse no-perms AccessControlContext object when performing isAuthorized check

Reviewed-by: wetmore
This commit is contained in:
Sean Mullan 2014-06-03 07:34:35 -04:00
parent 1eef4367df
commit 605924f8ef

View File

@ -592,14 +592,24 @@ public final class AccessController {
System.getSecurityManager() != null &&
!callerPD.impliesCreateAccessControlContext())
{
ProtectionDomain nullPD = new ProtectionDomain(null, null);
return new AccessControlContext(new ProtectionDomain[] { nullPD });
return getInnocuousAcc();
} else {
return new AccessControlContext(callerPD, combiner, parent,
context, perms);
}
}
private static class AccHolder {
// An AccessControlContext with no granted permissions.
// Only initialized on demand when getInnocuousAcc() is called.
static final AccessControlContext innocuousAcc =
new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, null) });
}
private static AccessControlContext getInnocuousAcc() {
return AccHolder.innocuousAcc;
}
private static ProtectionDomain getCallerPD(final Class <?> caller) {
ProtectionDomain callerPd = doPrivileged
(new PrivilegedAction<ProtectionDomain>() {