8267521: Post JEP 411 refactoring: maximum covering > 50K

Reviewed-by: dfuchs, prr
This commit is contained in:
Weijun Wang 2021-06-02 15:48:50 +00:00
parent 40d23a0c0b
commit 508cec7535
18 changed files with 205 additions and 104 deletions

View file

@ -178,7 +178,6 @@ import java.util.concurrent.locks.Condition;
* @since 1.7
* @author Doug Lea
*/
@SuppressWarnings("removal")
public class ForkJoinPool extends AbstractExecutorService {
/*
@ -751,11 +750,13 @@ public class ForkJoinPool extends AbstractExecutorService {
* permission to modify threads.
*/
private static void checkPermission() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null)
security.checkPermission(modifyThreadPermission);
}
@SuppressWarnings("removal")
static AccessControlContext contextWithPermissions(Permission ... perms) {
Permissions permissions = new Permissions();
for (Permission perm : perms)
@ -799,9 +800,11 @@ public class ForkJoinPool extends AbstractExecutorService {
static final class DefaultForkJoinWorkerThreadFactory
implements ForkJoinWorkerThreadFactory {
// ACC for access to the factory
@SuppressWarnings("removal")
private static final AccessControlContext ACC = contextWithPermissions(
new RuntimePermission("getClassLoader"),
new RuntimePermission("setContextClassLoader"));
@SuppressWarnings("removal")
public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
return AccessController.doPrivileged(
new PrivilegedAction<>() {
@ -821,6 +824,7 @@ public class ForkJoinPool extends AbstractExecutorService {
*/
static final class DefaultCommonPoolForkJoinWorkerThreadFactory
implements ForkJoinWorkerThreadFactory {
@SuppressWarnings("removal")
private static final AccessControlContext ACC = contextWithPermissions(
modifyThreadPermission,
new RuntimePermission("enableContextClassLoaderOverride"),
@ -828,6 +832,7 @@ public class ForkJoinPool extends AbstractExecutorService {
new RuntimePermission("getClassLoader"),
new RuntimePermission("setContextClassLoader"));
@SuppressWarnings("removal")
public final ForkJoinWorkerThread newThread(ForkJoinPool pool) {
return AccessController.doPrivileged(
new PrivilegedAction<>() {
@ -1253,11 +1258,13 @@ public class ForkJoinPool extends AbstractExecutorService {
// misc
/** AccessControlContext for innocuous workers, created on 1st use. */
@SuppressWarnings("removal")
private static AccessControlContext INNOCUOUS_ACC;
/**
* Initializes (upon registration) InnocuousForkJoinWorkerThreads.
*/
@SuppressWarnings("removal")
final void initializeInnocuousWorker() {
AccessControlContext acc; // racy construction OK
if ((acc = INNOCUOUS_ACC) == null)
@ -3497,9 +3504,11 @@ public class ForkJoinPool extends AbstractExecutorService {
defaultForkJoinWorkerThreadFactory =
new DefaultForkJoinWorkerThreadFactory();
modifyThreadPermission = new RuntimePermission("modifyThread");
common = AccessController.doPrivileged(new PrivilegedAction<>() {
@SuppressWarnings("removal")
ForkJoinPool tmp = AccessController.doPrivileged(new PrivilegedAction<>() {
public ForkJoinPool run() {
return new ForkJoinPool((byte)0); }});
common = tmp;
COMMON_PARALLELISM = Math.max(common.mode & SMASK, 1);
}

View file

@ -48,7 +48,6 @@ import sun.net.ftp.*;
import sun.util.logging.PlatformLogger;
@SuppressWarnings("removal")
public class FtpClient extends sun.net.ftp.FtpClient {
private static int defaultSoTimeout;
@ -111,16 +110,13 @@ public class FtpClient extends sun.net.ftp.FtpClient {
static {
final int vals[] = {0, 0};
final String encs[] = {null};
AccessController.doPrivileged(
new PrivilegedAction<Object>() {
public Object run() {
@SuppressWarnings("removal")
final String enc = AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
vals[0] = Integer.getInteger("sun.net.client.defaultReadTimeout", 300_000).intValue();
vals[1] = Integer.getInteger("sun.net.client.defaultConnectTimeout", 300_000).intValue();
encs[0] = System.getProperty("file.encoding", "ISO8859_1");
return null;
return System.getProperty("file.encoding", "ISO8859_1");
}
});
if (vals[0] == 0) {
@ -135,7 +131,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
defaultConnectTimeout = vals[1];
}
encoding = encs[0];
encoding = enc;
try {
if (!isASCIISuperset(encoding)) {
encoding = "ISO8859_1";
@ -632,13 +628,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
Socket s;
if (proxy != null) {
if (proxy.type() == Proxy.Type.SOCKS) {
s = AccessController.doPrivileged(
new PrivilegedAction<Socket>() {
public Socket run() {
return new Socket(proxy);
}
});
PrivilegedAction<Socket> pa = () -> new Socket(proxy);
@SuppressWarnings("removal")
var tmp = AccessController.doPrivileged(pa);
s = tmp;
} else {
s = new Socket(Proxy.NO_PROXY);
}
@ -646,13 +639,9 @@ public class FtpClient extends sun.net.ftp.FtpClient {
s = new Socket();
}
InetAddress serverAddress = AccessController.doPrivileged(
new PrivilegedAction<InetAddress>() {
@Override
public InetAddress run() {
return server.getLocalAddress();
}
});
PrivilegedAction<InetAddress> pa = () -> server.getLocalAddress();
@SuppressWarnings("removal")
InetAddress serverAddress = AccessController.doPrivileged(pa);
// Bind the socket to the same address as the control channel. This
// is needed in case of multi-homed systems.
@ -925,13 +914,10 @@ public class FtpClient extends sun.net.ftp.FtpClient {
Socket s;
if (proxy != null) {
if (proxy.type() == Proxy.Type.SOCKS) {
s = AccessController.doPrivileged(
new PrivilegedAction<Socket>() {
public Socket run() {
return new Socket(proxy);
}
});
PrivilegedAction<Socket> pa = () -> new Socket(proxy);
@SuppressWarnings("removal")
var tmp = AccessController.doPrivileged(pa);
s = tmp;
} else {
s = new Socket(Proxy.NO_PROXY);
}