AccessController.doPrivileged到底什么时候才能用到?
我看到代码里面大量出现AccessController.doPrivileged
相关的代码
public static InetAddress addressByName(final String hostname) throws UnknownHostException { try {
return AccessController.doPrivileged(new PrivilegedExceptionAction<InetAddress>() {
@Override
public InetAddress run() throws UnknownHostException {
return InetAddress.getByName(hostname);
}
});
} catch (PrivilegedActionException e) {
throw (UnknownHostException) e.getCause();
}
}
我目前不清楚的是:什么时候才能用到,我不写这个AccessController.doPrivileged会有什么问题?有大佬可以举个例子吗?
以上是 AccessController.doPrivileged到底什么时候才能用到? 的全部内容, 来源链接: utcz.com/p/944820.html