java.security 源码学习06 PrivilegedAction
作者:互联网
1. 源码
/**
A computation to be performed with privileges enabled. The computation is
performed by invoking {@code AccessController.doPrivileged} on the
{@code PrivilegedAction} object. This interface is used only for
computations that do not throw checked exceptions; computations that
throw checked exceptions must use {@code PrivilegedExceptionAction}
instead.
启用权限时执行的计算。通过在{@code PrivilegedAction}对象上调用
{@code AccessController.doPrivileged}来执行计算。
此接口仅用于不抛出已检查异常的计算;
抛出已检查异常的计算必须使用{@code PrivilegedExceptionAction}。
*
* @see AccessController
* @see AccessController#doPrivileged(PrivilegedAction)
* @see PrivilegedExceptionAction
*/
public interface PrivilegedAction<T> {
/**
Performs the computation. This method will be called by
{@code AccessController.doPrivileged} after enabling privileges.
执行计算。启用权限后,{@code AccessController.doPrivileged}将调用此方法。
@return a class-dependent value that may represent the results of the
computation. Each class that implements
{@code PrivilegedAction}
should document what (if anything) this value represents.
@see AccessController#doPrivileged(PrivilegedAction)
@see AccessController#doPrivileged(PrivilegedAction,
AccessControlContext)
*/
T run();
}
标签:code,06,PrivilegedAction,doPrivileged,AccessController,see,源码,computation 来源: https://blog.csdn.net/weixin_38389755/article/details/93743036