8266459: Implement JEP 411: Deprecate the Security Manager for Removal

Co-authored-by: Sean Mullan <mullan@openjdk.org>
Co-authored-by: Lance Andersen <lancea@openjdk.org>
Co-authored-by: Weijun Wang <weijun@openjdk.org>
Reviewed-by: erikj, darcy, chegar, naoto, joehw, alanb, mchung, kcr, prr, lancea
This commit is contained in:
Weijun Wang 2021-06-02 11:57:31 +00:00
parent 19450b9951
commit 6765f90250
826 changed files with 2734 additions and 757 deletions

View File

@ -767,7 +767,7 @@ define SetupRunJtregTestBody
-vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \ -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \
-vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)" -vmoption:-Djava.io.tmpdir="$$($1_TEST_TMP_DIR)"
$1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet $1_JTREG_BASIC_OPTIONS += -automatic -ignore:quiet -Djavatest.security.noSecurityManager=true
# Make it possible to specify the JIB_DATA_DIR for tests using the # Make it possible to specify the JIB_DATA_DIR for tests using the
# JIB Artifact resolver # JIB Artifact resolver

View File

@ -1,6 +1,6 @@
/* /*
* *
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -406,7 +406,7 @@ public final class Tools extends JPanel implements ActionListener,
if (pDialogState) { if (pDialogState) {
printJob.print(aset); printJob.print(aset);
} }
} catch (java.security.AccessControlException ace) { } catch (@SuppressWarnings("removal") java.security.AccessControlException ace) {
String errmsg = "Applet access control exception; to allow " String errmsg = "Applet access control exception; to allow "
+ "access to printer, set\n" + "access to printer, set\n"
+ "permission for \"queuePrintJob\" in " + "permission for \"queuePrintJob\" in "

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.security.PrivilegedAction;
* Creates this platform's default SelectorProvider * Creates this platform's default SelectorProvider
*/ */
@SuppressWarnings("removal")
public class DefaultSelectorProvider { public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE; private static final SelectorProviderImpl INSTANCE;
static { static {

View File

@ -39,6 +39,7 @@ import java.util.stream.Stream;
public final class CgroupUtil { public final class CgroupUtil {
@SuppressWarnings("removal")
public static Stream<String> readFilePrivileged(Path path) throws IOException { public static Stream<String> readFilePrivileged(Path path) throws IOException {
try { try {
PrivilegedExceptionAction<Stream<String>> pea = () -> Files.lines(path); PrivilegedExceptionAction<Stream<String>> pea = () -> Files.lines(path);
@ -64,7 +65,7 @@ public final class CgroupUtil {
static String readStringValue(CgroupSubsystemController controller, String param) throws IOException { static String readStringValue(CgroupSubsystemController controller, String param) throws IOException {
PrivilegedExceptionAction<BufferedReader> pea = () -> PrivilegedExceptionAction<BufferedReader> pea = () ->
Files.newBufferedReader(Paths.get(controller.path(), param)); Files.newBufferedReader(Paths.get(controller.path(), param));
try (BufferedReader bufferedReader = try (@SuppressWarnings("removal") BufferedReader bufferedReader =
AccessController.doPrivileged(pea)) { AccessController.doPrivileged(pea)) {
String line = bufferedReader.readLine(); String line = bufferedReader.readLine();
return line; return line;
@ -76,6 +77,7 @@ public final class CgroupUtil {
} }
} }
@SuppressWarnings("removal")
public static List<String> readAllLinesPrivileged(Path path) throws IOException { public static List<String> readAllLinesPrivileged(Path path) throws IOException {
try { try {
PrivilegedExceptionAction<List<String>> pea = () -> Files.readAllLines(path); PrivilegedExceptionAction<List<String>> pea = () -> Files.readAllLines(path);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.security.PrivilegedAction;
* Creates this platform's default SelectorProvider * Creates this platform's default SelectorProvider
*/ */
@SuppressWarnings("removal")
public class DefaultSelectorProvider { public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE; private static final SelectorProviderImpl INSTANCE;
static { static {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,7 @@ public final class AppleProvider extends Provider {
} }
@SuppressWarnings("removal")
public AppleProvider() { public AppleProvider() {
/* We are the Apple provider */ /* We are the Apple provider */
super("Apple", PROVIDER_VER, info); super("Apple", PROVIDER_VER, info);

View File

@ -110,6 +110,7 @@ public final class KeychainStore extends KeyStoreSpi {
} }
private static void permissionCheck() { private static void permissionCheck() {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -106,6 +106,7 @@ class DefaultInterface {
boolean ip4 = false, ip6 = false, isNonLinkLocal = false; boolean ip4 = false, ip6 = false, isNonLinkLocal = false;
PrivilegedAction<Enumeration<InetAddress>> pa = ni::getInetAddresses; PrivilegedAction<Enumeration<InetAddress>> pa = ni::getInetAddresses;
@SuppressWarnings("removal")
Enumeration<InetAddress> addrs = AccessController.doPrivileged(pa); Enumeration<InetAddress> addrs = AccessController.doPrivileged(pa);
while (addrs.hasMoreElements()) { while (addrs.hasMoreElements()) {
InetAddress addr = addrs.nextElement(); InetAddress addr = addrs.nextElement();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ import java.security.PrivilegedAction;
* Creates this platform's default SelectorProvider * Creates this platform's default SelectorProvider
*/ */
@SuppressWarnings("removal")
public class DefaultSelectorProvider { public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE; private static final SelectorProviderImpl INSTANCE;
static { static {

View File

@ -66,6 +66,7 @@ extends KeyAgreementSpi {
private static final boolean VALUE = getValue(); private static final boolean VALUE = getValue();
@SuppressWarnings("removal")
private static boolean getValue() { private static boolean getValue() {
return AccessController.doPrivileged( return AccessController.doPrivileged(
(PrivilegedAction<Boolean>) (PrivilegedAction<Boolean>)

View File

@ -683,6 +683,7 @@ public final class JceKeyStore extends KeyStoreSpi {
* @exception CertificateException if any of the certificates in the * @exception CertificateException if any of the certificates in the
* keystore could not be loaded * keystore could not be loaded
*/ */
@SuppressWarnings("removal")
public void engineLoad(InputStream stream, char[] password) public void engineLoad(InputStream stream, char[] password)
throws IOException, NoSuchAlgorithmException, CertificateException throws IOException, NoSuchAlgorithmException, CertificateException
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,7 @@ final class SealedObjectForKeyProtector extends SealedObject {
return params; return params;
} }
@SuppressWarnings("removal")
final Key getKey(Cipher c, int maxLength) final Key getKey(Cipher c, int maxLength)
throws IOException, ClassNotFoundException, IllegalBlockSizeException, throws IOException, ClassNotFoundException, IllegalBlockSizeException,
BadPaddingException { BadPaddingException {
@ -112,6 +113,7 @@ final class SealedObjectForKeyProtector extends SealedObject {
private static final ObjectInputFilter OWN_FILTER; private static final ObjectInputFilter OWN_FILTER;
static { static {
@SuppressWarnings("removal")
String prop = AccessController.doPrivileged( String prop = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> { (PrivilegedAction<String>) () -> {
String tmp = System.getProperty(KEY_SERIAL_FILTER); String tmp = System.getProperty(KEY_SERIAL_FILTER);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -117,6 +117,7 @@ public final class SunJCE extends Provider {
attrs)); attrs));
} }
@SuppressWarnings("removal")
public SunJCE() { public SunJCE() {
/* We are the "SunJCE" provider */ /* We are the "SunJCE" provider */
super("SunJCE", PROVIDER_VER, info); super("SunJCE", PROVIDER_VER, info);

View File

@ -770,6 +770,7 @@ public class File
* method denies read access to the file * method denies read access to the file
*/ */
public boolean canRead() { public boolean canRead() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -798,6 +799,7 @@ public class File
* method denies write access to the file * method denies write access to the file
*/ */
public boolean canWrite() { public boolean canWrite() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -821,6 +823,7 @@ public class File
* method denies read access to the file or directory * method denies read access to the file or directory
*/ */
public boolean exists() { public boolean exists() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -851,6 +854,7 @@ public class File
* method denies read access to the file * method denies read access to the file
*/ */
public boolean isDirectory() { public boolean isDirectory() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -883,6 +887,7 @@ public class File
* method denies read access to the file * method denies read access to the file
*/ */
public boolean isFile() { public boolean isFile() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -912,6 +917,7 @@ public class File
* @since 1.2 * @since 1.2
*/ */
public boolean isHidden() { public boolean isHidden() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -955,6 +961,7 @@ public class File
* method denies read access to the file * method denies read access to the file
*/ */
public long lastModified() { public long lastModified() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -986,6 +993,7 @@ public class File
* method denies read access to the file * method denies read access to the file
*/ */
public long length() { public long length() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -1026,6 +1034,7 @@ public class File
* @since 1.2 * @since 1.2
*/ */
public boolean createNewFile() throws IOException { public boolean createNewFile() throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) security.checkWrite(path); if (security != null) security.checkWrite(path);
if (isInvalid()) { if (isInvalid()) {
@ -1053,6 +1062,7 @@ public class File
* delete access to the file * delete access to the file
*/ */
public boolean delete() { public boolean delete() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkDelete(path); security.checkDelete(path);
@ -1091,6 +1101,7 @@ public class File
* @since 1.2 * @since 1.2
*/ */
public void deleteOnExit() { public void deleteOnExit() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkDelete(path); security.checkDelete(path);
@ -1154,6 +1165,7 @@ public class File
* the directory * the directory
*/ */
private final String[] normalizedList() { private final String[] normalizedList() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(path); security.checkRead(path);
@ -1356,6 +1368,7 @@ public class File
* method does not permit the named directory to be created * method does not permit the named directory to be created
*/ */
public boolean mkdir() { public boolean mkdir() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1438,6 +1451,7 @@ public class File
if (dest == null) { if (dest == null) {
throw new NullPointerException(); throw new NullPointerException();
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1477,6 +1491,7 @@ public class File
*/ */
public boolean setLastModified(long time) { public boolean setLastModified(long time) {
if (time < 0) throw new IllegalArgumentException("Negative time"); if (time < 0) throw new IllegalArgumentException("Negative time");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1507,6 +1522,7 @@ public class File
* @since 1.2 * @since 1.2
*/ */
public boolean setReadOnly() { public boolean setReadOnly() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1550,6 +1566,7 @@ public class File
* @since 1.6 * @since 1.6
*/ */
public boolean setWritable(boolean writable, boolean ownerOnly) { public boolean setWritable(boolean writable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1628,6 +1645,7 @@ public class File
* @since 1.6 * @since 1.6
*/ */
public boolean setReadable(boolean readable, boolean ownerOnly) { public boolean setReadable(boolean readable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1709,6 +1727,7 @@ public class File
* @since 1.6 * @since 1.6
*/ */
public boolean setExecutable(boolean executable, boolean ownerOnly) { public boolean setExecutable(boolean executable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(path); security.checkWrite(path);
@ -1772,6 +1791,7 @@ public class File
* @since 1.6 * @since 1.6
*/ */
public boolean canExecute() { public boolean canExecute() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkExec(path); security.checkExec(path);
@ -1854,6 +1874,7 @@ public class File
* @see FileStore#getTotalSpace * @see FileStore#getTotalSpace
*/ */
public long getTotalSpace() { public long getTotalSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@ -1897,6 +1918,7 @@ public class File
* @see FileStore#getUnallocatedSpace * @see FileStore#getUnallocatedSpace
*/ */
public long getFreeSpace() { public long getFreeSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@ -1943,6 +1965,7 @@ public class File
* @see FileStore#getUsableSpace * @see FileStore#getUsableSpace
*/ */
public long getUsableSpace() { public long getUsableSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
@ -1977,6 +2000,7 @@ public class File
} }
return subNameLength; return subNameLength;
} }
@SuppressWarnings("removal")
static File generateFile(String prefix, String suffix, File dir) static File generateFile(String prefix, String suffix, File dir)
throws IOException throws IOException
{ {
@ -2125,6 +2149,7 @@ public class File
File tmpdir = (directory != null) ? directory File tmpdir = (directory != null) ? directory
: TempDirectory.location(); : TempDirectory.location();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
File f; File f;
do { do {

View File

@ -140,6 +140,7 @@ public class FileInputStream extends InputStream
*/ */
public FileInputStream(File file) throws FileNotFoundException { public FileInputStream(File file) throws FileNotFoundException {
String name = (file != null ? file.getPath() : null); String name = (file != null ? file.getPath() : null);
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(name); security.checkRead(name);
@ -182,6 +183,7 @@ public class FileInputStream extends InputStream
* @see SecurityManager#checkRead(java.io.FileDescriptor) * @see SecurityManager#checkRead(java.io.FileDescriptor)
*/ */
public FileInputStream(FileDescriptor fdObj) { public FileInputStream(FileDescriptor fdObj) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (fdObj == null) { if (fdObj == null) {
throw new NullPointerException(); throw new NullPointerException();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -217,6 +217,7 @@ public class FileOutputStream extends OutputStream
throws FileNotFoundException throws FileNotFoundException
{ {
String name = (file != null ? file.getPath() : null); String name = (file != null ? file.getPath() : null);
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkWrite(name); security.checkWrite(name);
@ -259,6 +260,7 @@ public class FileOutputStream extends OutputStream
* @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor) * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
*/ */
public FileOutputStream(FileDescriptor fdObj) { public FileOutputStream(FileDescriptor fdObj) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (fdObj == null) { if (fdObj == null) {
throw new NullPointerException(); throw new NullPointerException();

View File

@ -308,6 +308,7 @@ public final class FilePermission extends Permission implements Serializable {
* @param mask the actions mask to use. * @param mask the actions mask to use.
* *
*/ */
@SuppressWarnings("removal")
private void init(int mask) { private void init(int mask) {
if ((mask & ALL) != mask) if ((mask & ALL) != mask)
throw new IllegalArgumentException("invalid actions mask"); throw new IllegalArgumentException("invalid actions mask");

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -219,6 +219,7 @@ public interface ObjectInputFilter {
* *
* @since 9 * @since 9
*/ */
@SuppressWarnings("removal")
final class Config { final class Config {
/* No instances. */ /* No instances. */
private Config() {} private Config() {}

View File

@ -404,6 +404,7 @@ public class ObjectInputStream
* @see java.io.SerializablePermission * @see java.io.SerializablePermission
*/ */
protected ObjectInputStream() throws IOException, SecurityException { protected ObjectInputStream() throws IOException, SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
@ -915,6 +916,7 @@ public class ObjectInputStream
return enable; return enable;
} }
if (enable) { if (enable) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SUBSTITUTION_PERMISSION); sm.checkPermission(SUBSTITUTION_PERMISSION);
@ -1307,6 +1309,7 @@ public class ObjectInputStream
* @since 9 * @since 9
*/ */
public final void setObjectInputFilter(ObjectInputFilter filter) { public final void setObjectInputFilter(ObjectInputFilter filter) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION); sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
@ -1575,6 +1578,7 @@ public class ObjectInputStream
if (cl == ObjectInputStream.class) { if (cl == ObjectInputStream.class) {
return; return;
} }
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm == null) { if (sm == null) {
return; return;
@ -1596,6 +1600,7 @@ public class ObjectInputStream
* override security-sensitive non-final methods. Returns TRUE if subclass * override security-sensitive non-final methods. Returns TRUE if subclass
* is "safe", FALSE otherwise. * is "safe", FALSE otherwise.
*/ */
@SuppressWarnings("removal")
private static Boolean auditSubclass(Class<?> subcl) { private static Boolean auditSubclass(Class<?> subcl) {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<Boolean>() { new PrivilegedAction<Boolean>() {
@ -2660,10 +2665,11 @@ public class ObjectInputStream
final ObjectInputValidation obj; final ObjectInputValidation obj;
final int priority; final int priority;
Callback next; Callback next;
@SuppressWarnings("removal")
final AccessControlContext acc; final AccessControlContext acc;
Callback(ObjectInputValidation obj, int priority, Callback next, Callback(ObjectInputValidation obj, int priority, Callback next,
AccessControlContext acc) @SuppressWarnings("removal") AccessControlContext acc)
{ {
this.obj = obj; this.obj = obj;
this.priority = priority; this.priority = priority;
@ -2697,6 +2703,7 @@ public class ObjectInputStream
prev = cur; prev = cur;
cur = cur.next; cur = cur.next;
} }
@SuppressWarnings("removal")
AccessControlContext acc = AccessController.getContext(); AccessControlContext acc = AccessController.getContext();
if (prev != null) { if (prev != null) {
prev.next = new Callback(obj, priority, cur, acc); prev.next = new Callback(obj, priority, cur, acc);
@ -2712,6 +2719,7 @@ public class ObjectInputStream
* throws an InvalidObjectException, the callback process is terminated * throws an InvalidObjectException, the callback process is terminated
* and the exception propagated upwards. * and the exception propagated upwards.
*/ */
@SuppressWarnings("removal")
void doCallbacks() throws InvalidObjectException { void doCallbacks() throws InvalidObjectException {
try { try {
while (list != null) { while (list != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -213,6 +213,7 @@ public class ObjectOutputStream
* value of "sun.io.serialization.extendedDebugInfo" property, * value of "sun.io.serialization.extendedDebugInfo" property,
* as true or false for extended information about exception's place * as true or false for extended information about exception's place
*/ */
@SuppressWarnings("removal")
private static final boolean extendedDebugInfo = private static final boolean extendedDebugInfo =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction( new sun.security.action.GetBooleanAction(
@ -274,6 +275,7 @@ public class ObjectOutputStream
* @see java.io.SerializablePermission * @see java.io.SerializablePermission
*/ */
protected ObjectOutputStream() throws IOException, SecurityException { protected ObjectOutputStream() throws IOException, SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION);
@ -621,6 +623,7 @@ public class ObjectOutputStream
return enable; return enable;
} }
if (enable) { if (enable) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SUBSTITUTION_PERMISSION); sm.checkPermission(SUBSTITUTION_PERMISSION);
@ -1052,6 +1055,7 @@ public class ObjectOutputStream
if (cl == ObjectOutputStream.class) { if (cl == ObjectOutputStream.class) {
return; return;
} }
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm == null) { if (sm == null) {
return; return;
@ -1073,6 +1077,7 @@ public class ObjectOutputStream
* override security-sensitive non-final methods. Returns TRUE if subclass * override security-sensitive non-final methods. Returns TRUE if subclass
* is "safe", FALSE otherwise. * is "safe", FALSE otherwise.
*/ */
@SuppressWarnings("removal")
private static Boolean auditSubclass(Class<?> subcl) { private static Boolean auditSubclass(Class<?> subcl) {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {

View File

@ -101,6 +101,7 @@ public class ObjectStreamClass implements Serializable {
NO_FIELDS; NO_FIELDS;
/** reflection factory for obtaining serialization constructors */ /** reflection factory for obtaining serialization constructors */
@SuppressWarnings("removal")
private static final ReflectionFactory reflFactory = private static final ReflectionFactory reflFactory =
AccessController.doPrivileged( AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction()); new ReflectionFactory.GetReflectionFactoryAction());
@ -278,6 +279,7 @@ public class ObjectStreamClass implements Serializable {
* *
* @return the SUID of the class described by this descriptor * @return the SUID of the class described by this descriptor
*/ */
@SuppressWarnings("removal")
public long getSerialVersionUID() { public long getSerialVersionUID() {
// REMIND: synchronize instead of relying on volatile? // REMIND: synchronize instead of relying on volatile?
if (suid == null) { if (suid == null) {
@ -301,6 +303,7 @@ public class ObjectStreamClass implements Serializable {
* *
* @return the {@code Class} instance that this descriptor represents * @return the {@code Class} instance that this descriptor represents
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public Class<?> forClass() { public Class<?> forClass() {
if (cl == null) { if (cl == null) {
@ -460,6 +463,7 @@ public class ObjectStreamClass implements Serializable {
* Returns the value contained by this EntryFuture, blocking if * Returns the value contained by this EntryFuture, blocking if
* necessary until a value is set. * necessary until a value is set.
*/ */
@SuppressWarnings("removal")
synchronized Object get() { synchronized Object get() {
boolean interrupted = false; boolean interrupted = false;
while (entry == unset) { while (entry == unset) {
@ -493,6 +497,7 @@ public class ObjectStreamClass implements Serializable {
/** /**
* Creates local class descriptor representing given class. * Creates local class descriptor representing given class.
*/ */
@SuppressWarnings("removal")
private ObjectStreamClass(final Class<?> cl) { private ObjectStreamClass(final Class<?> cl) {
this.cl = cl; this.cl = cl;
name = cl.getName(); name = cl.getName();
@ -620,6 +625,7 @@ public class ObjectStreamClass implements Serializable {
* ProtectionDomain that separate the concrete class {@code cl} * ProtectionDomain that separate the concrete class {@code cl}
* from its ancestor's declaring {@code cons}, or {@code null}. * from its ancestor's declaring {@code cons}, or {@code null}.
*/ */
@SuppressWarnings("removal")
private ProtectionDomain[] getProtectionDomains(Constructor<?> cons, private ProtectionDomain[] getProtectionDomains(Constructor<?> cons,
Class<?> cl) { Class<?> cl) {
ProtectionDomain[] domains = null; ProtectionDomain[] domains = null;
@ -1130,6 +1136,7 @@ public class ObjectStreamClass implements Serializable {
* class is non-serializable or if the appropriate no-arg constructor is * class is non-serializable or if the appropriate no-arg constructor is
* inaccessible/unavailable. * inaccessible/unavailable.
*/ */
@SuppressWarnings("removal")
Object newInstance() Object newInstance()
throws InstantiationException, InvocationTargetException, throws InstantiationException, InvocationTargetException,
UnsupportedOperationException UnsupportedOperationException
@ -1572,6 +1579,7 @@ public class ObjectStreamClass implements Serializable {
* the not found ( which should never happen for correctly generated record * the not found ( which should never happen for correctly generated record
* classes ). * classes ).
*/ */
@SuppressWarnings("removal")
private static MethodHandle canonicalRecordCtr(Class<?> cls) { private static MethodHandle canonicalRecordCtr(Class<?> cls) {
assert cls.isRecord() : "Expected record, got: " + cls; assert cls.isRecord() : "Expected record, got: " + cls;
PrivilegedAction<MethodHandle> pa = () -> { PrivilegedAction<MethodHandle> pa = () -> {
@ -2584,6 +2592,7 @@ public class ObjectStreamClass implements Serializable {
* and return * and return
* {@code Object} * {@code Object}
*/ */
@SuppressWarnings("removal")
static MethodHandle deserializationCtr(ObjectStreamClass desc) { static MethodHandle deserializationCtr(ObjectStreamClass desc) {
// check the cached value 1st // check the cached value 1st
MethodHandle mh = desc.deserializationCtr; MethodHandle mh = desc.deserializationCtr;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -213,6 +213,7 @@ public class ObjectStreamField
* @return a {@code Class} object representing the type of the * @return a {@code Class} object representing the type of the
* serializable field * serializable field
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public Class<?> getType() { public Class<?> getType() {
if (System.getSecurityManager() != null) { if (System.getSecurityManager() != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -239,6 +239,7 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
+ "\" must be one of " + "\" must be one of "
+ "\"r\", \"rw\", \"rws\"," + "\"r\", \"rw\", \"rws\","
+ " or \"rwd\""); + " or \"rwd\"");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkRead(name); security.checkRead(name);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -48,7 +48,7 @@ class CharacterName {
private final int[] hsIndices; // chain heads, hash indices into "cps" private final int[] hsIndices; // chain heads, hash indices into "cps"
private CharacterName() { private CharacterName() {
try (DataInputStream dis = new DataInputStream(new InflaterInputStream( try (@SuppressWarnings("removal") DataInputStream dis = new DataInputStream(new InflaterInputStream(
AccessController.doPrivileged(new PrivilegedAction<>() { AccessController.doPrivileged(new PrivilegedAction<>() {
public InputStream run() { public InputStream run() {
return getClass().getResourceAsStream("uniName.dat"); return getClass().getResourceAsStream("uniName.dat");

View File

@ -450,6 +450,7 @@ public final class Class<T> implements java.io.Serializable,
throws ClassNotFoundException throws ClassNotFoundException
{ {
Class<?> caller = null; Class<?> caller = null;
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// Reflective call to get caller class is only needed if a security manager // Reflective call to get caller class is only needed if a security manager
@ -519,6 +520,7 @@ public final class Class<T> implements java.io.Serializable,
* @jls 12.3 Linking of Classes and Interfaces * @jls 12.3 Linking of Classes and Interfaces
* @since 9 * @since 9
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public static Class<?> forName(Module module, String name) { public static Class<?> forName(Module module, String name) {
Objects.requireNonNull(module); Objects.requireNonNull(module);
@ -599,6 +601,7 @@ public final class Class<T> implements java.io.Serializable,
* s.checkPackageAccess()} denies access to the package * s.checkPackageAccess()} denies access to the package
* of this class. * of this class.
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
@Deprecated(since="9") @Deprecated(since="9")
public T newInstance() public T newInstance()
@ -892,6 +895,7 @@ public final class Class<T> implements java.io.Serializable,
ClassLoader cl = getClassLoader0(); ClassLoader cl = getClassLoader0();
if (cl == null) if (cl == null)
return null; return null;
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
ClassLoader.checkClassLoaderPermission(cl, Reflection.getCallerClass()); ClassLoader.checkClassLoaderPermission(cl, Reflection.getCallerClass());
@ -1357,6 +1361,7 @@ public final class Class<T> implements java.io.Serializable,
// Perform access check // Perform access check
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, enclosingCandidate.checkMemberAccess(sm, Member.DECLARED,
@ -1513,6 +1518,7 @@ public final class Class<T> implements java.io.Serializable,
// Perform access check // Perform access check
final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass(); final Class<?> enclosingCandidate = enclosingInfo.getEnclosingClass();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, enclosingCandidate.checkMemberAccess(sm, Member.DECLARED,
@ -1560,6 +1566,7 @@ public final class Class<T> implements java.io.Serializable,
final Class<?> candidate = getDeclaringClass0(); final Class<?> candidate = getDeclaringClass0();
if (candidate != null) { if (candidate != null) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
candidate.checkPackageAccess(sm, candidate.checkPackageAccess(sm,
@ -1614,6 +1621,7 @@ public final class Class<T> implements java.io.Serializable,
} }
if (enclosingCandidate != null) { if (enclosingCandidate != null) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
enclosingCandidate.checkPackageAccess(sm, enclosingCandidate.checkPackageAccess(sm,
@ -1840,6 +1848,7 @@ public final class Class<T> implements java.io.Serializable,
* *
* @since 1.1 * @since 1.1
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public Class<?>[] getClasses() { public Class<?>[] getClasses() {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
@ -1911,6 +1920,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Field[] getFields() throws SecurityException { public Field[] getFields() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2001,6 +2011,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Method[] getMethods() throws SecurityException { public Method[] getMethods() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2041,6 +2052,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Constructor<?>[] getConstructors() throws SecurityException { public Constructor<?>[] getConstructors() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2095,6 +2107,7 @@ public final class Class<T> implements java.io.Serializable,
public Field getField(String name) public Field getField(String name)
throws NoSuchFieldException, SecurityException { throws NoSuchFieldException, SecurityException {
Objects.requireNonNull(name); Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2204,6 +2217,7 @@ public final class Class<T> implements java.io.Serializable,
public Method getMethod(String name, Class<?>... parameterTypes) public Method getMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException { throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name); Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2248,6 +2262,7 @@ public final class Class<T> implements java.io.Serializable,
public Constructor<T> getConstructor(Class<?>... parameterTypes) public Constructor<T> getConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException throws NoSuchMethodException, SecurityException
{ {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
@ -2295,6 +2310,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Class<?>[] getDeclaredClasses() throws SecurityException { public Class<?>[] getDeclaredClasses() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false);
@ -2347,6 +2363,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Field[] getDeclaredFields() throws SecurityException { public Field[] getDeclaredFields() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2408,6 +2425,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public RecordComponent[] getRecordComponents() { public RecordComponent[] getRecordComponents() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2478,6 +2496,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Method[] getDeclaredMethods() throws SecurityException { public Method[] getDeclaredMethods() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2528,6 +2547,7 @@ public final class Class<T> implements java.io.Serializable,
*/ */
@CallerSensitive @CallerSensitive
public Constructor<?>[] getDeclaredConstructors() throws SecurityException { public Constructor<?>[] getDeclaredConstructors() throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2580,6 +2600,7 @@ public final class Class<T> implements java.io.Serializable,
public Field getDeclaredField(String name) public Field getDeclaredField(String name)
throws NoSuchFieldException, SecurityException { throws NoSuchFieldException, SecurityException {
Objects.requireNonNull(name); Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2644,6 +2665,7 @@ public final class Class<T> implements java.io.Serializable,
public Method getDeclaredMethod(String name, Class<?>... parameterTypes) public Method getDeclaredMethod(String name, Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException { throws NoSuchMethodException, SecurityException {
Objects.requireNonNull(name); Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2722,6 +2744,7 @@ public final class Class<T> implements java.io.Serializable,
public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes) public Constructor<T> getDeclaredConstructor(Class<?>... parameterTypes)
throws NoSuchMethodException, SecurityException throws NoSuchMethodException, SecurityException
{ {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true);
@ -2968,6 +2991,7 @@ public final class Class<T> implements java.io.Serializable,
* @since 1.2 * @since 1.2
*/ */
public java.security.ProtectionDomain getProtectionDomain() { public java.security.ProtectionDomain getProtectionDomain() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_PD_PERMISSION); sm.checkPermission(SecurityConstants.GET_PD_PERMISSION);
@ -3013,7 +3037,7 @@ public final class Class<T> implements java.io.Serializable,
* *
* <p> NOTE: should only be called if a SecurityManager is installed * <p> NOTE: should only be called if a SecurityManager is installed
*/ */
private void checkMemberAccess(SecurityManager sm, int which, private void checkMemberAccess(@SuppressWarnings("removal") SecurityManager sm, int which,
Class<?> caller, boolean checkProxyInterfaces) { Class<?> caller, boolean checkProxyInterfaces) {
/* Default policy allows access to all {@link Member#PUBLIC} members, /* Default policy allows access to all {@link Member#PUBLIC} members,
* as well as access to classes that have the same class loader as the caller. * as well as access to classes that have the same class loader as the caller.
@ -3037,7 +3061,7 @@ public final class Class<T> implements java.io.Serializable,
* *
* NOTE: this method should only be called if a SecurityManager is active * NOTE: this method should only be called if a SecurityManager is active
*/ */
private void checkPackageAccess(SecurityManager sm, final ClassLoader ccl, private void checkPackageAccess(@SuppressWarnings("removal") SecurityManager sm, final ClassLoader ccl,
boolean checkProxyInterfaces) { boolean checkProxyInterfaces) {
final ClassLoader cl = getClassLoader0(); final ClassLoader cl = getClassLoader0();
@ -3066,7 +3090,7 @@ public final class Class<T> implements java.io.Serializable,
* all classes provided must be loaded by the same ClassLoader * all classes provided must be loaded by the same ClassLoader
* NOTE: this method does not support Proxy classes * NOTE: this method does not support Proxy classes
*/ */
private static void checkPackageAccessForPermittedSubclasses(SecurityManager sm, private static void checkPackageAccessForPermittedSubclasses(@SuppressWarnings("removal") SecurityManager sm,
final ClassLoader ccl, Class<?>[] subClasses) { final ClassLoader ccl, Class<?>[] subClasses) {
final ClassLoader cl = subClasses[0].getClassLoader0(); final ClassLoader cl = subClasses[0].getClassLoader0();
@ -3762,6 +3786,7 @@ public final class Class<T> implements java.io.Serializable,
} }
// Fetches the factory for reflective objects // Fetches the factory for reflective objects
@SuppressWarnings("removal")
private static ReflectionFactory getReflectionFactory() { private static ReflectionFactory getReflectionFactory() {
if (reflectionFactory == null) { if (reflectionFactory == null) {
reflectionFactory = reflectionFactory =
@ -3794,6 +3819,7 @@ public final class Class<T> implements java.io.Serializable,
* identical to getEnumConstants except that the result is * identical to getEnumConstants except that the result is
* uncloned, cached, and shared by all callers. * uncloned, cached, and shared by all callers.
*/ */
@SuppressWarnings("removal")
T[] getEnumConstantsShared() { T[] getEnumConstantsShared() {
T[] constants = enumConstants; T[] constants = enumConstants;
if (constants == null) { if (constants == null) {
@ -4204,6 +4230,7 @@ public final class Class<T> implements java.io.Serializable,
return this; return this;
} }
// returning a different class requires a security check // returning a different class requires a security check
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkPackageAccess(sm, checkPackageAccess(sm,
@ -4296,6 +4323,7 @@ public final class Class<T> implements java.io.Serializable,
if (members.length > 1) { if (members.length > 1) {
// If we return anything other than the current class we need // If we return anything other than the current class we need
// a security check // a security check
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkPackageAccess(sm, checkPackageAccess(sm,
@ -4492,6 +4520,7 @@ public final class Class<T> implements java.io.Serializable,
} }
if (subClasses.length > 0) { if (subClasses.length > 0) {
// If we return some classes we need a security check: // If we return some classes we need a security check:
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkPackageAccessForPermittedSubclasses(sm, checkPackageAccessForPermittedSubclasses(sm,

View File

@ -365,6 +365,7 @@ public abstract class ClassLoader {
throw new IllegalArgumentException("name must be non-empty or null"); throw new IllegalArgumentException("name must be non-empty or null");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkCreateClassLoader(); security.checkCreateClassLoader();
@ -671,6 +672,7 @@ public abstract class ClassLoader {
} }
// Invoked by the VM after loading class with this loader. // Invoked by the VM after loading class with this loader.
@SuppressWarnings("removal")
private void checkPackageAccess(Class<?> cls, ProtectionDomain pd) { private void checkPackageAccess(Class<?> cls, ProtectionDomain pd) {
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
@ -1791,6 +1793,7 @@ public abstract class ClassLoader {
public final ClassLoader getParent() { public final ClassLoader getParent() {
if (parent == null) if (parent == null)
return null; return null;
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// Check access to the parent class loader // Check access to the parent class loader
@ -1834,6 +1837,7 @@ public abstract class ClassLoader {
*/ */
@CallerSensitive @CallerSensitive
public static ClassLoader getPlatformClassLoader() { public static ClassLoader getPlatformClassLoader() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
ClassLoader loader = getBuiltinPlatformClassLoader(); ClassLoader loader = getBuiltinPlatformClassLoader();
if (sm != null) { if (sm != null) {
@ -1933,6 +1937,7 @@ public abstract class ClassLoader {
default: default:
// system fully initialized // system fully initialized
assert VM.isBooted() && scl != null; assert VM.isBooted() && scl != null;
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkClassLoaderPermission(scl, Reflection.getCallerClass()); checkClassLoaderPermission(scl, Reflection.getCallerClass());
@ -2041,6 +2046,7 @@ public abstract class ClassLoader {
* is not the same as or an ancestor of the given cl argument. * is not the same as or an ancestor of the given cl argument.
*/ */
static void checkClassLoaderPermission(ClassLoader cl, Class<?> caller) { static void checkClassLoaderPermission(ClassLoader cl, Class<?> caller) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// caller can be null if the VM is requesting it // caller can be null if the VM is requesting it

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -177,6 +177,7 @@ interface LiveStackFrame extends StackFrame {
* and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}. * and it denies access to {@code RuntimePermission("getStackWalkerWithClassReference")}.
*/ */
public static StackWalker getStackWalker(Set<StackWalker.Option> options) { public static StackWalker getStackWalker(Set<StackWalker.Option> options) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("liveStackFrames")); sm.checkPermission(new RuntimePermission("liveStackFrames"));

View File

@ -204,6 +204,7 @@ public final class Module implements AnnotatedElement {
* If denied by the security manager * If denied by the security manager
*/ */
public ClassLoader getClassLoader() { public ClassLoader getClassLoader() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);
@ -1471,6 +1472,7 @@ public final class Module implements AnnotatedElement {
// cached class file with annotations // cached class file with annotations
private volatile Class<?> moduleInfoClass; private volatile Class<?> moduleInfoClass;
@SuppressWarnings("removal")
private Class<?> moduleInfoClass() { private Class<?> moduleInfoClass() {
Class<?> clazz = this.moduleInfoClass; Class<?> clazz = this.moduleInfoClass;
if (clazz != null) if (clazz != null)

View File

@ -699,12 +699,14 @@ public final class ModuleLayer {
} }
private static void checkCreateClassLoaderPermission() { private static void checkCreateClassLoaderPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION); sm.checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION);
} }
private static void checkGetClassLoaderPermission() { private static void checkGetClassLoaderPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -425,6 +425,7 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated
String cn = packageName() + ".package-info"; String cn = packageName() + ".package-info";
Module module = module(); Module module = module();
PrivilegedAction<ClassLoader> pa = module::getClassLoader; PrivilegedAction<ClassLoader> pa = module::getClassLoader;
@SuppressWarnings("removal")
ClassLoader loader = AccessController.doPrivileged(pa); ClassLoader loader = AccessController.doPrivileged(pa);
Class<?> c; Class<?> c;
if (loader != null) { if (loader != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -348,6 +348,7 @@ public final class ProcessBuilder
* @see System#getenv() * @see System#getenv()
*/ */
public Map<String,String> environment() { public Map<String,String> environment() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) if (security != null)
security.checkPermission(new RuntimePermission("getenv.*")); security.checkPermission(new RuntimePermission("getenv.*"));
@ -1092,6 +1093,7 @@ public final class ProcessBuilder
// Throws IndexOutOfBoundsException if command is empty // Throws IndexOutOfBoundsException if command is empty
String prog = cmdarray[0]; String prog = cmdarray[0];
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) if (security != null)
security.checkExec(prog); security.checkExec(prog);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -25,6 +25,7 @@
package java.lang; package java.lang;
import java.lang.annotation.Native; import java.lang.annotation.Native;
import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.time.Duration; import java.time.Duration;
import java.time.Instant; import java.time.Instant;
@ -40,8 +41,6 @@ import java.util.concurrent.ThreadLocalRandom;
import java.util.stream.IntStream; import java.util.stream.IntStream;
import java.util.stream.Stream; import java.util.stream.Stream;
import static java.security.AccessController.doPrivileged;
/** /**
* ProcessHandleImpl is the implementation of ProcessHandle. * ProcessHandleImpl is the implementation of ProcessHandle.
* *
@ -83,8 +82,9 @@ final class ProcessHandleImpl implements ProcessHandle {
/** /**
* The thread pool of "process reaper" daemon threads. * The thread pool of "process reaper" daemon threads.
*/ */
@SuppressWarnings("removal")
private static final Executor processReaperExecutor = private static final Executor processReaperExecutor =
doPrivileged((PrivilegedAction<Executor>) () -> { AccessController.doPrivileged((PrivilegedAction<Executor>) () -> {
// Initialize ThreadLocalRandom now to avoid using the smaller stack // Initialize ThreadLocalRandom now to avoid using the smaller stack
// of the processReaper threads. // of the processReaper threads.
ThreadLocalRandom.current(); ThreadLocalRandom.current();
@ -238,6 +238,7 @@ final class ProcessHandleImpl implements ProcessHandle {
* @throws SecurityException if RuntimePermission("manageProcess") is not granted * @throws SecurityException if RuntimePermission("manageProcess") is not granted
*/ */
static Optional<ProcessHandle> get(long pid) { static Optional<ProcessHandle> get(long pid) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess")); sm.checkPermission(new RuntimePermission("manageProcess"));
@ -278,6 +279,7 @@ final class ProcessHandleImpl implements ProcessHandle {
* @throws SecurityException if RuntimePermission("manageProcess") is not granted * @throws SecurityException if RuntimePermission("manageProcess") is not granted
*/ */
public static ProcessHandleImpl current() { public static ProcessHandleImpl current() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess")); sm.checkPermission(new RuntimePermission("manageProcess"));
@ -301,6 +303,7 @@ final class ProcessHandleImpl implements ProcessHandle {
* security policy * security policy
*/ */
public Optional<ProcessHandle> parent() { public Optional<ProcessHandle> parent() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess")); sm.checkPermission(new RuntimePermission("manageProcess"));
@ -419,6 +422,7 @@ final class ProcessHandleImpl implements ProcessHandle {
* @return a stream of ProcessHandles * @return a stream of ProcessHandles
*/ */
static Stream<ProcessHandle> children(long pid) { static Stream<ProcessHandle> children(long pid) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess")); sm.checkPermission(new RuntimePermission("manageProcess"));
@ -439,6 +443,7 @@ final class ProcessHandleImpl implements ProcessHandle {
@Override @Override
public Stream<ProcessHandle> descendants() { public Stream<ProcessHandle> descendants() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("manageProcess")); sm.checkPermission(new RuntimePermission("manageProcess"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -88,6 +88,7 @@ final class PublicMethods {
* Method (name, parameter types) tuple. * Method (name, parameter types) tuple.
*/ */
private static final class Key { private static final class Key {
@SuppressWarnings("removal")
private static final ReflectionFactory reflectionFactory = private static final ReflectionFactory reflectionFactory =
AccessController.doPrivileged( AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction()); new ReflectionFactory.GetReflectionFactoryAction());

View File

@ -107,6 +107,7 @@ public class Runtime {
* @see #halt(int) * @see #halt(int)
*/ */
public void exit(int status) { public void exit(int status) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkExit(status); security.checkExit(status);
@ -207,6 +208,7 @@ public class Runtime {
* @since 1.3 * @since 1.3
*/ */
public void addShutdownHook(Thread hook) { public void addShutdownHook(Thread hook) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("shutdownHooks")); sm.checkPermission(new RuntimePermission("shutdownHooks"));
@ -235,6 +237,7 @@ public class Runtime {
* @since 1.3 * @since 1.3
*/ */
public boolean removeShutdownHook(Thread hook) { public boolean removeShutdownHook(Thread hook) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("shutdownHooks")); sm.checkPermission(new RuntimePermission("shutdownHooks"));
@ -270,6 +273,7 @@ public class Runtime {
* @since 1.3 * @since 1.3
*/ */
public void halt(int status) { public void halt(int status) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkExit(status); sm.checkExit(status);
@ -734,6 +738,7 @@ public class Runtime {
} }
void load0(Class<?> fromClass, String filename) { void load0(Class<?> fromClass, String filename) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkLink(filename); security.checkLink(filename);
@ -797,6 +802,7 @@ public class Runtime {
} }
void loadLibrary0(Class<?> fromClass, String libname) { void loadLibrary0(Class<?> fromClass, String libname) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkLink(libname); security.checkLink(libname);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -79,9 +79,9 @@ import sun.security.util.SecurityConstants;
* permitted. * permitted.
* <p> * <p>
* Environments using a security manager will typically set the security * Environments using a security manager will typically set the security
* manager at startup. In the JDK implementation, this is done by setting * manager at startup. In the JDK implementation, this is done by setting the
* the system property {@code java.security.manager} on the command line to * system property {@systemProperty java.security.manager} on the command line
* the class name of the security manager. It can also be set to the empty * to the class name of the security manager. It can also be set to the empty
* String ("") or the special token "{@code default}" to use the * String ("") or the special token "{@code default}" to use the
* default {@code java.lang.SecurityManager}. If a class name is specified, * default {@code java.lang.SecurityManager}. If a class name is specified,
* it must be {@code java.lang.SecurityManager} or a public subclass and have * it must be {@code java.lang.SecurityManager} or a public subclass and have
@ -313,7 +313,12 @@ import sun.security.util.SecurityConstants;
* @see java.security.ProtectionDomain * @see java.security.ProtectionDomain
* *
* @since 1.0 * @since 1.0
* @deprecated The Security Manager is deprecated and subject to removal in a
* future release. There is no replacement for the Security Manager.
* See <a href="https://openjdk.java.net/jeps/411">JEP 411</a> for
* discussion and alternatives.
*/ */
@Deprecated(since="17", forRemoval=true)
public class SecurityManager { public class SecurityManager {
/* /*
@ -340,6 +345,7 @@ public class SecurityManager {
*/ */
public SecurityManager() { public SecurityManager() {
synchronized(SecurityManager.class) { synchronized(SecurityManager.class) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// ask the currently installed security manager if we // ask the currently installed security manager if we
@ -385,6 +391,7 @@ public class SecurityManager {
* java.lang.Object) checkRead * java.lang.Object) checkRead
* @see java.security.AccessControlContext AccessControlContext * @see java.security.AccessControlContext AccessControlContext
*/ */
@SuppressWarnings("removal")
public Object getSecurityContext() { public Object getSecurityContext() {
return AccessController.getContext(); return AccessController.getContext();
} }
@ -404,6 +411,7 @@ public class SecurityManager {
* {@code null}. * {@code null}.
* @since 1.2 * @since 1.2
*/ */
@SuppressWarnings("removal")
public void checkPermission(Permission perm) { public void checkPermission(Permission perm) {
java.security.AccessController.checkPermission(perm); java.security.AccessController.checkPermission(perm);
} }
@ -439,6 +447,7 @@ public class SecurityManager {
* @see java.security.AccessControlContext#checkPermission(java.security.Permission) * @see java.security.AccessControlContext#checkPermission(java.security.Permission)
* @since 1.2 * @since 1.2
*/ */
@SuppressWarnings("removal")
public void checkPermission(Permission perm, Object context) { public void checkPermission(Permission perm, Object context) {
if (context instanceof AccessControlContext) { if (context instanceof AccessControlContext) {
((AccessControlContext)context).checkPermission(perm); ((AccessControlContext)context).checkPermission(perm);
@ -1081,10 +1090,9 @@ public class SecurityManager {
* @throws NullPointerException if the address argument is * @throws NullPointerException if the address argument is
* {@code null}. * {@code null}.
* @since 1.1 * @since 1.1
* @deprecated Use #checkPermission(java.security.Permission) instead
* @see #checkPermission(java.security.Permission) checkPermission * @see #checkPermission(java.security.Permission) checkPermission
*/ */
@Deprecated(since="1.4") @Deprecated(since="1.4", forRemoval=true)
public void checkMulticast(InetAddress maddr, byte ttl) { public void checkMulticast(InetAddress maddr, byte ttl) {
String host = maddr.getHostAddress(); String host = maddr.getHostAddress();
if (!host.startsWith("[") && host.indexOf(':') != -1) { if (!host.startsWith("[") && host.indexOf(':') != -1) {
@ -1332,6 +1340,7 @@ public class SecurityManager {
* Do we need to update our property array? * Do we need to update our property array?
*/ */
if (!packageAccessValid) { if (!packageAccessValid) {
@SuppressWarnings("removal")
String tmpPropertyStr = String tmpPropertyStr =
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
@ -1431,6 +1440,7 @@ public class SecurityManager {
* Do we need to update our property array? * Do we need to update our property array?
*/ */
if (!packageDefinitionValid) { if (!packageDefinitionValid) {
@SuppressWarnings("removal")
String tmpPropertyStr = String tmpPropertyStr =
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -418,6 +418,7 @@ public final class StackWalker {
private static void checkPermission(Set<Option> options) { private static void checkPermission(Set<Option> options) {
Objects.requireNonNull(options); Objects.requireNonNull(options);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
if (options.contains(Option.RETAIN_CLASS_REFERENCE)) { if (options.contains(Option.RETAIN_CLASS_REFERENCE)) {

View File

@ -517,6 +517,7 @@ public final class String
* *
* @since 1.6 * @since 1.6
*/ */
@SuppressWarnings("removal")
public String(byte[] bytes, int offset, int length, Charset charset) { public String(byte[] bytes, int offset, int length, Charset charset) {
Objects.requireNonNull(charset); Objects.requireNonNull(charset);
checkBoundsOffCount(offset, length, bytes.length); checkBoundsOffCount(offset, length, bytes.length);
@ -745,6 +746,7 @@ public final class String
} }
} }
@SuppressWarnings("removal")
private static String newStringNoRepl1(byte[] src, Charset cs) { private static String newStringNoRepl1(byte[] src, Charset cs) {
int len = src.length; int len = src.length;
if (len == 0) { if (len == 0) {
@ -794,6 +796,7 @@ public final class String
private static final char REPL = '\ufffd'; private static final char REPL = '\ufffd';
// Trim the given byte array to the given length // Trim the given byte array to the given length
@SuppressWarnings("removal")
private static byte[] safeTrim(byte[] ba, int len, boolean isTrusted) { private static byte[] safeTrim(byte[] ba, int len, boolean isTrusted) {
if (len == ba.length && (isTrusted || System.getSecurityManager() == null)) { if (len == ba.length && (isTrusted || System.getSecurityManager() == null)) {
return ba; return ba;

View File

@ -181,6 +181,7 @@ public final class System {
private static @Stable int allowSecurityManager; private static @Stable int allowSecurityManager;
// current security manager // current security manager
@SuppressWarnings("removal")
private static volatile SecurityManager security; // read by VM private static volatile SecurityManager security; // read by VM
// return true if a security manager is allowed // return true if a security manager is allowed
@ -312,6 +313,7 @@ public final class System {
} }
private static void checkIO() { private static void checkIO() {
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("setIO")); sm.checkPermission(new RuntimePermission("setIO"));
@ -352,26 +354,19 @@ public final class System {
* @see #getSecurityManager * @see #getSecurityManager
* @see SecurityManager#checkPermission * @see SecurityManager#checkPermission
* @see java.lang.RuntimePermission * @see java.lang.RuntimePermission
* @deprecated This method is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this method is also deprecated and subject to
* removal. There is no replacement for the Security Manager or this
* method.
*/ */
public static void setSecurityManager(SecurityManager sm) { @Deprecated(since="17", forRemoval=true)
public static void setSecurityManager(@SuppressWarnings("removal") SecurityManager sm) {
if (allowSecurityManager()) { if (allowSecurityManager()) {
if (security == null) { System.err.println("WARNING: java.lang.System::setSecurityManager" +
// ensure image reader is initialized " is deprecated and will be removed in a future release.");
Object.class.getResource("java/lang/ANY"); implSetSecurityManager(sm);
// ensure the default file system is initialized
DefaultFileSystemProvider.theFileSystem();
}
if (sm != null) {
try {
// pre-populates the SecurityManager.packageAccess cache
// to avoid recursive permission checking issues with custom
// SecurityManager implementations
sm.checkPackageAccess("java.lang");
} catch (Exception e) {
// no-op
}
}
setSecurityManager0(sm);
} else { } else {
// security manager not allowed // security manager not allowed
if (sm != null) { if (sm != null) {
@ -381,6 +376,27 @@ public final class System {
} }
} }
private static void implSetSecurityManager(@SuppressWarnings("removal") SecurityManager sm) {
if (security == null) {
// ensure image reader is initialized
Object.class.getResource("java/lang/ANY");
// ensure the default file system is initialized
DefaultFileSystemProvider.theFileSystem();
}
if (sm != null) {
try {
// pre-populates the SecurityManager.packageAccess cache
// to avoid recursive permission checking issues with custom
// SecurityManager implementations
sm.checkPackageAccess("java.lang");
} catch (Exception e) {
// no-op
}
}
setSecurityManager0(sm);
}
@SuppressWarnings("removal")
private static synchronized private static synchronized
void setSecurityManager0(final SecurityManager s) { void setSecurityManager0(final SecurityManager s) {
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
@ -418,7 +434,15 @@ public final class System {
* current application, then that security manager is returned; * current application, then that security manager is returned;
* otherwise, {@code null} is returned. * otherwise, {@code null} is returned.
* @see #setSecurityManager * @see #setSecurityManager
* @deprecated This method is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this method is also deprecated and subject to
* removal. There is no replacement for the Security Manager or this
* method.
*/ */
@SuppressWarnings("removal")
@Deprecated(since="17", forRemoval=true)
public static SecurityManager getSecurityManager() { public static SecurityManager getSecurityManager() {
if (allowSecurityManager()) { if (allowSecurityManager()) {
return security; return security;
@ -750,6 +774,7 @@ public final class System {
* @see java.util.Properties * @see java.util.Properties
*/ */
public static Properties getProperties() { public static Properties getProperties() {
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPropertiesAccess(); sm.checkPropertiesAccess();
@ -802,6 +827,7 @@ public final class System {
* @see java.lang.SecurityManager#checkPropertiesAccess() * @see java.lang.SecurityManager#checkPropertiesAccess()
*/ */
public static void setProperties(Properties props) { public static void setProperties(Properties props) {
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPropertiesAccess(); sm.checkPropertiesAccess();
@ -847,6 +873,7 @@ public final class System {
*/ */
public static String getProperty(String key) { public static String getProperty(String key) {
checkKey(key); checkKey(key);
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPropertyAccess(key); sm.checkPropertyAccess(key);
@ -882,6 +909,7 @@ public final class System {
*/ */
public static String getProperty(String key, String def) { public static String getProperty(String key, String def) {
checkKey(key); checkKey(key);
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPropertyAccess(key); sm.checkPropertyAccess(key);
@ -925,6 +953,7 @@ public final class System {
*/ */
public static String setProperty(String key, String value) { public static String setProperty(String key, String value) {
checkKey(key); checkKey(key);
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new PropertyPermission(key, sm.checkPermission(new PropertyPermission(key,
@ -966,6 +995,7 @@ public final class System {
*/ */
public static String clearProperty(String key) { public static String clearProperty(String key) {
checkKey(key); checkKey(key);
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new PropertyPermission(key, "write")); sm.checkPermission(new PropertyPermission(key, "write"));
@ -1030,6 +1060,7 @@ public final class System {
* @see ProcessBuilder#environment() * @see ProcessBuilder#environment()
*/ */
public static String getenv(String name) { public static String getenv(String name) {
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("getenv."+name)); sm.checkPermission(new RuntimePermission("getenv."+name));
@ -1079,6 +1110,7 @@ public final class System {
* @since 1.5 * @since 1.5
*/ */
public static java.util.Map<String,String> getenv() { public static java.util.Map<String,String> getenv() {
@SuppressWarnings("removal")
SecurityManager sm = getSecurityManager(); SecurityManager sm = getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("getenv.*")); sm.checkPermission(new RuntimePermission("getenv.*"));
@ -1546,6 +1578,7 @@ public final class System {
} }
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(LOGGERFINDER_PERMISSION); sm.checkPermission(LOGGERFINDER_PERMISSION);
@ -1629,6 +1662,7 @@ public final class System {
* {@code RuntimePermission("loggerFinder")}. * {@code RuntimePermission("loggerFinder")}.
*/ */
public static LoggerFinder getLoggerFinder() { public static LoggerFinder getLoggerFinder() {
@SuppressWarnings("removal")
final SecurityManager sm = System.getSecurityManager(); final SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(LOGGERFINDER_PERMISSION); sm.checkPermission(LOGGERFINDER_PERMISSION);
@ -1638,6 +1672,7 @@ public final class System {
private static volatile LoggerFinder service; private static volatile LoggerFinder service;
@SuppressWarnings("removal")
static LoggerFinder accessProvider() { static LoggerFinder accessProvider() {
// We do not need to synchronize: LoggerFinderLoader will // We do not need to synchronize: LoggerFinderLoader will
// always return the same instance, so if we don't have it, // always return the same instance, so if we don't have it,
@ -1741,6 +1776,7 @@ public final class System {
* *
* @since 9 * @since 9
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public static Logger getLogger(String name, ResourceBundle bundle) { public static Logger getLogger(String name, ResourceBundle bundle) {
final ResourceBundle rb = Objects.requireNonNull(bundle); final ResourceBundle rb = Objects.requireNonNull(bundle);
@ -2103,6 +2139,7 @@ public final class System {
* The security manager and system class loader may be a custom class from * The security manager and system class loader may be a custom class from
* the application classpath or modulepath. * the application classpath or modulepath.
*/ */
@SuppressWarnings("removal")
private static void initPhase3() { private static void initPhase3() {
// Initialize the StringConcatFactory eagerly to avoid potential // Initialize the StringConcatFactory eagerly to avoid potential
@ -2111,6 +2148,7 @@ public final class System {
Unsafe.getUnsafe().ensureClassInitialized(StringConcatFactory.class); Unsafe.getUnsafe().ensureClassInitialized(StringConcatFactory.class);
String smProp = System.getProperty("java.security.manager"); String smProp = System.getProperty("java.security.manager");
boolean needWarning = false;
if (smProp != null) { if (smProp != null) {
switch (smProp) { switch (smProp) {
case "disallow": case "disallow":
@ -2121,8 +2159,9 @@ public final class System {
break; break;
case "": case "":
case "default": case "default":
setSecurityManager(new SecurityManager()); implSetSecurityManager(new SecurityManager());
allowSecurityManager = MAYBE; allowSecurityManager = MAYBE;
needWarning = true;
break; break;
default: default:
try { try {
@ -2140,7 +2179,8 @@ public final class System {
// custom security manager may be in non-exported package // custom security manager may be in non-exported package
ctor.setAccessible(true); ctor.setAccessible(true);
SecurityManager sm = (SecurityManager) ctor.newInstance(); SecurityManager sm = (SecurityManager) ctor.newInstance();
setSecurityManager(sm); implSetSecurityManager(sm);
needWarning = true;
} catch (Exception e) { } catch (Exception e) {
throw new InternalError("Could not create SecurityManager", e); throw new InternalError("Could not create SecurityManager", e);
} }
@ -2150,6 +2190,11 @@ public final class System {
allowSecurityManager = MAYBE; allowSecurityManager = MAYBE;
} }
if (needWarning) {
System.err.println("WARNING: The Security Manager is deprecated" +
" and will be removed in a future release.");
}
// initializing the system class loader // initializing the system class loader
VM.initLevel(3); VM.initLevel(3);
@ -2200,7 +2245,7 @@ public final class System {
public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) { public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
Shutdown.add(slot, registerShutdownInProgress, hook); Shutdown.add(slot, registerShutdownInProgress, hook);
} }
public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) { public Thread newThreadWithAcc(Runnable target, @SuppressWarnings("removal") AccessControlContext acc) {
return new Thread(target, acc); return new Thread(target, acc);
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -2226,9 +2271,11 @@ public final class System {
public String fastUUID(long lsb, long msb) { public String fastUUID(long lsb, long msb) {
return Long.fastUUID(lsb, msb); return Long.fastUUID(lsb, msb);
} }
@SuppressWarnings("removal")
public void addNonExportedPackages(ModuleLayer layer) { public void addNonExportedPackages(ModuleLayer layer) {
SecurityManager.addNonExportedPackages(layer); SecurityManager.addNonExportedPackages(layer);
} }
@SuppressWarnings("removal")
public void invalidatePackageAccessCache() { public void invalidatePackageAccessCache() {
SecurityManager.invalidatePackageAccessCache(); SecurityManager.invalidatePackageAccessCache();
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1994, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -169,6 +169,7 @@ public class Thread implements Runnable {
private ClassLoader contextClassLoader; private ClassLoader contextClassLoader;
/* The inherited AccessControlContext of this thread */ /* The inherited AccessControlContext of this thread */
@SuppressWarnings("removal")
private AccessControlContext inheritedAccessControlContext; private AccessControlContext inheritedAccessControlContext;
/* For autonumbering anonymous threads. */ /* For autonumbering anonymous threads. */
@ -388,6 +389,7 @@ public class Thread implements Runnable {
* @param inheritThreadLocals if {@code true}, inherit initial values for * @param inheritThreadLocals if {@code true}, inherit initial values for
* inheritable thread-locals from the constructing thread * inheritable thread-locals from the constructing thread
*/ */
@SuppressWarnings("removal")
private Thread(ThreadGroup g, Runnable target, String name, private Thread(ThreadGroup g, Runnable target, String name,
long stackSize, AccessControlContext acc, long stackSize, AccessControlContext acc,
boolean inheritThreadLocals) { boolean inheritThreadLocals) {
@ -496,7 +498,7 @@ public class Thread implements Runnable {
* but thread-local variables are not inherited. * but thread-local variables are not inherited.
* This is not a public constructor. * This is not a public constructor.
*/ */
Thread(Runnable target, AccessControlContext acc) { Thread(Runnable target, @SuppressWarnings("removal") AccessControlContext acc) {
this(null, target, "Thread-" + nextThreadNum(), 0, acc, false); this(null, target, "Thread-" + nextThreadNum(), 0, acc, false);
} }
@ -922,6 +924,7 @@ public class Thread implements Runnable {
*/ */
@Deprecated(since="1.2") @Deprecated(since="1.2")
public final void stop() { public final void stop() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
checkAccess(); checkAccess();
@ -1424,8 +1427,16 @@ public class Thread implements Runnable {
* @throws SecurityException if the current thread is not allowed to * @throws SecurityException if the current thread is not allowed to
* access this thread. * access this thread.
* @see SecurityManager#checkAccess(Thread) * @see SecurityManager#checkAccess(Thread)
* @deprecated This method is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this method is also deprecated and subject to
* removal. There is no replacement for the Security Manager or this
* method.
*/ */
@Deprecated(since="17", forRemoval=true)
public final void checkAccess() { public final void checkAccess() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkAccess(this); security.checkAccess(this);
@ -1476,6 +1487,7 @@ public class Thread implements Runnable {
public ClassLoader getContextClassLoader() { public ClassLoader getContextClassLoader() {
if (contextClassLoader == null) if (contextClassLoader == null)
return null; return null;
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
ClassLoader.checkClassLoaderPermission(contextClassLoader, ClassLoader.checkClassLoaderPermission(contextClassLoader,
@ -1507,6 +1519,7 @@ public class Thread implements Runnable {
* @since 1.2 * @since 1.2
*/ */
public void setContextClassLoader(ClassLoader cl) { public void setContextClassLoader(ClassLoader cl) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new RuntimePermission("setContextClassLoader")); sm.checkPermission(new RuntimePermission("setContextClassLoader"));
@ -1574,6 +1587,7 @@ public class Thread implements Runnable {
public StackTraceElement[] getStackTrace() { public StackTraceElement[] getStackTrace() {
if (this != Thread.currentThread()) { if (this != Thread.currentThread()) {
// check for getStackTrace permission // check for getStackTrace permission
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkPermission( security.checkPermission(
@ -1634,6 +1648,7 @@ public class Thread implements Runnable {
*/ */
public static Map<Thread, StackTraceElement[]> getAllStackTraces() { public static Map<Thread, StackTraceElement[]> getAllStackTraces() {
// check for getStackTrace permission // check for getStackTrace permission
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkPermission( security.checkPermission(
@ -1696,6 +1711,7 @@ public class Thread implements Runnable {
* subclass overrides any of the methods, false otherwise. * subclass overrides any of the methods, false otherwise.
*/ */
private static boolean auditSubclass(final Class<?> subcl) { private static boolean auditSubclass(final Class<?> subcl) {
@SuppressWarnings("removal")
Boolean result = AccessController.doPrivileged( Boolean result = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
public Boolean run() { public Boolean run() {
@ -1927,6 +1943,7 @@ public class Thread implements Runnable {
* @since 1.5 * @since 1.5
*/ */
public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) { public static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler eh) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission( sm.checkPermission(

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -320,8 +320,16 @@ public class ThreadGroup implements Thread.UncaughtExceptionHandler {
* access this thread group. * access this thread group.
* @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup) * @see java.lang.SecurityManager#checkAccess(java.lang.ThreadGroup)
* @since 1.0 * @since 1.0
* @deprecated This method is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this method is also deprecated and subject to
* removal. There is no replacement for the Security Manager or this
* method.
*/ */
@Deprecated(since="17", forRemoval=true)
public final void checkAccess() { public final void checkAccess() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkAccess(this); security.checkAccess(this);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -134,6 +134,7 @@ final class MethodTypeDescImpl implements MethodTypeDesc {
@Override @Override
public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException { public MethodType resolveConstantDesc(MethodHandles.Lookup lookup) throws ReflectiveOperationException {
@SuppressWarnings("removal")
MethodType mtype = AccessController.doPrivileged(new PrivilegedAction<>() { MethodType mtype = AccessController.doPrivileged(new PrivilegedAction<>() {
@Override @Override
public MethodType run() { public MethodType run() {

View File

@ -566,6 +566,7 @@ abstract class ClassSpecializer<T,K,S extends ClassSpecializer<T,K,S>.SpeciesDat
* @param speciesData what species we are generating * @param speciesData what species we are generating
* @return the generated concrete TopClass class * @return the generated concrete TopClass class
*/ */
@SuppressWarnings("removal")
Class<? extends T> generateConcreteSpeciesCode(String className, ClassSpecializer<T,K,S>.SpeciesData speciesData) { Class<? extends T> generateConcreteSpeciesCode(String className, ClassSpecializer<T,K,S>.SpeciesData speciesData) {
byte[] classFile = generateConcreteSpeciesCodeFile(className, speciesData); byte[] classFile = generateConcreteSpeciesCodeFile(className, speciesData);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -87,6 +87,7 @@ final class InfoFromMemberName implements MethodHandleInfo {
// For more information see comments on {@link MethodHandleNatives#linkMethod}. // For more information see comments on {@link MethodHandleNatives#linkMethod}.
throw new IllegalArgumentException("cannot reflect signature polymorphic method"); throw new IllegalArgumentException("cannot reflect signature polymorphic method");
} }
@SuppressWarnings("removal")
Member mem = AccessController.doPrivileged(new PrivilegedAction<>() { Member mem = AccessController.doPrivileged(new PrivilegedAction<>() {
public Member run() { public Member run() {
try { try {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -228,6 +228,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
"Exception finding " + LAMBDA_INSTANCE_FIELD + " static field", e); "Exception finding " + LAMBDA_INSTANCE_FIELD + " static field", e);
} }
} else { } else {
@SuppressWarnings("removal")
final Constructor<?>[] ctrs = AccessController.doPrivileged( final Constructor<?>[] ctrs = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
@Override @Override
@ -319,6 +320,7 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
* @throws LambdaConversionException If properly formed functional interface * @throws LambdaConversionException If properly formed functional interface
* is not found * is not found
*/ */
@SuppressWarnings("removal")
private Class<?> generateInnerClass() throws LambdaConversionException { private Class<?> generateInnerClass() throws LambdaConversionException {
String[] interfaces; String[] interfaces;
String samIntf = samBase.getName().replace('.', '/'); String samIntf = samBase.getName().replace('.', '/');

View File

@ -202,6 +202,7 @@ class InvokerBytecodeGenerator {
} }
// Also used from BoundMethodHandle // Also used from BoundMethodHandle
@SuppressWarnings("removal")
static void maybeDump(final String className, final byte[] classFile) { static void maybeDump(final String className, final byte[] classFile) {
if (DUMP_CLASS_FILES) { if (DUMP_CLASS_FILES) {
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -151,6 +151,7 @@ public class MethodHandleProxies {
// entry points, must be covered by hand-written or automatically // entry points, must be covered by hand-written or automatically
// generated adapter classes. // generated adapter classes.
// //
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public static <T> T asInterfaceInstance(final Class<T> intfc, final MethodHandle target) { public static <T> T asInterfaceInstance(final Class<T> intfc, final MethodHandle target) {
if (!intfc.isInterface() || !Modifier.isPublic(intfc.getModifiers())) if (!intfc.isInterface() || !Modifier.isPublic(intfc.getModifiers()))

View File

@ -228,6 +228,7 @@ public class MethodHandles {
return new Lookup(targetClass); return new Lookup(targetClass);
} }
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(ACCESS_PERMISSION); if (sm != null) sm.checkPermission(ACCESS_PERMISSION);
if (targetClass.isPrimitive()) if (targetClass.isPrimitive())
@ -440,6 +441,7 @@ public class MethodHandles {
* @since 1.8 * @since 1.8
*/ */
public static <T extends Member> T reflectAs(Class<T> expected, MethodHandle target) { public static <T extends Member> T reflectAs(Class<T> expected, MethodHandle target) {
@SuppressWarnings("removal")
SecurityManager smgr = System.getSecurityManager(); SecurityManager smgr = System.getSecurityManager();
if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION); if (smgr != null) smgr.checkPermission(ACCESS_PERMISSION);
Lookup lookup = Lookup.IMPL_LOOKUP; // use maximally privileged lookup Lookup lookup = Lookup.IMPL_LOOKUP; // use maximally privileged lookup
@ -1845,6 +1847,7 @@ public class MethodHandles {
if (allowedModes == TRUSTED) return; if (allowedModes == TRUSTED) return;
if (!hasFullPrivilegeAccess()) { if (!hasFullPrivilegeAccess()) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("defineClass")); sm.checkPermission(new RuntimePermission("defineClass"));
@ -3740,6 +3743,7 @@ return mh1;
void checkSecurityManager(Class<?> refc) { void checkSecurityManager(Class<?> refc) {
if (allowedModes == TRUSTED) return; if (allowedModes == TRUSTED) return;
@SuppressWarnings("removal")
SecurityManager smgr = System.getSecurityManager(); SecurityManager smgr = System.getSecurityManager();
if (smgr == null) return; if (smgr == null) return;
@ -3771,6 +3775,7 @@ return mh1;
if (allowedModes == TRUSTED) return; if (allowedModes == TRUSTED) return;
@SuppressWarnings("removal")
SecurityManager smgr = System.getSecurityManager(); SecurityManager smgr = System.getSecurityManager();
if (smgr == null) return; if (smgr == null) return;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -1134,6 +1134,7 @@ class MethodType
throws IllegalArgumentException, TypeNotPresentException throws IllegalArgumentException, TypeNotPresentException
{ {
if (loader == null) { if (loader == null) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -56,6 +56,7 @@ final class ProxyClassesDumper {
private final Path dumpDir; private final Path dumpDir;
@SuppressWarnings("removal")
public static ProxyClassesDumper getInstance(String path) { public static ProxyClassesDumper getInstance(String path) {
if (null == path) { if (null == path) {
return null; return null;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -265,6 +265,7 @@ public final class SerializedLambda implements Serializable {
@java.io.Serial @java.io.Serial
private Object readResolve() throws ObjectStreamException { private Object readResolve() throws ObjectStreamException {
try { try {
@SuppressWarnings("removal")
Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<>() { Method deserialize = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
@Override @Override
public Method run() throws Exception { public Method run() throws Exception {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -148,6 +148,7 @@ public interface ModuleFinder {
* @throws SecurityException * @throws SecurityException
* If denied by the security manager * If denied by the security manager
*/ */
@SuppressWarnings("removal")
static ModuleFinder ofSystem() { static ModuleFinder ofSystem() {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -105,6 +105,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
* The advantage of creating a fresh thread, however, is that it insulates * The advantage of creating a fresh thread, however, is that it insulates
* invokers of that method from a stalled or deadlocked finalizer thread. * invokers of that method from a stalled or deadlocked finalizer thread.
*/ */
@SuppressWarnings("removal")
private static void forkSecondaryFinalizer(final Runnable proc) { private static void forkSecondaryFinalizer(final Runnable proc) {
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {

View File

@ -82,6 +82,7 @@ public class AccessibleObject implements AnnotatedElement {
} }
static void checkPermission() { static void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// SecurityConstants.ACCESS_PERMISSION is used to check // SecurityConstants.ACCESS_PERMISSION is used to check
@ -483,6 +484,7 @@ public class AccessibleObject implements AnnotatedElement {
// Reflection factory used by subclasses for creating field, // Reflection factory used by subclasses for creating field,
// method, and constructor accessors. Note that this is called // method, and constructor accessors. Note that this is called
// very early in the bootstrapping process. // very early in the bootstrapping process.
@SuppressWarnings("removal")
static final ReflectionFactory reflectionFactory = static final ReflectionFactory reflectionFactory =
AccessController.doPrivileged( AccessController.doPrivileged(
new ReflectionFactory.GetReflectionFactoryAction()); new ReflectionFactory.GetReflectionFactoryAction());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -390,6 +390,7 @@ public class Proxy implements java.io.Serializable {
Class<?>... interfaces) Class<?>... interfaces)
throws IllegalArgumentException throws IllegalArgumentException
{ {
@SuppressWarnings("removal")
Class<?> caller = System.getSecurityManager() == null Class<?> caller = System.getSecurityManager() == null
? null ? null
: Reflection.getCallerClass(); : Reflection.getCallerClass();
@ -463,6 +464,7 @@ public class Proxy implements java.io.Serializable {
ClassLoader loader, ClassLoader loader,
Class<?> ... interfaces) Class<?> ... interfaces)
{ {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
ClassLoader ccl = caller.getClassLoader(); ClassLoader ccl = caller.getClassLoader();
@ -663,6 +665,7 @@ public class Proxy implements java.io.Serializable {
* Must call the checkProxyAccess method to perform permission checks * Must call the checkProxyAccess method to perform permission checks
* before calling this. * before calling this.
*/ */
@SuppressWarnings("removal")
Constructor<?> build() { Constructor<?> build() {
Class<?> proxyClass = defineProxyClass(module, interfaces); Class<?> proxyClass = defineProxyClass(module, interfaces);
assert !module.isNamed() || module.isOpen(proxyClass.getPackageName(), Proxy.class.getModule()); assert !module.isNamed() || module.isOpen(proxyClass.getPackageName(), Proxy.class.getModule());
@ -1018,6 +1021,7 @@ public class Proxy implements java.io.Serializable {
InvocationHandler h) { InvocationHandler h) {
Objects.requireNonNull(h); Objects.requireNonNull(h);
@SuppressWarnings("removal")
final Class<?> caller = System.getSecurityManager() == null final Class<?> caller = System.getSecurityManager() == null
? null ? null
: Reflection.getCallerClass(); : Reflection.getCallerClass();
@ -1055,6 +1059,7 @@ public class Proxy implements java.io.Serializable {
} }
private static void checkNewProxyPermission(Class<?> caller, Class<?> proxyClass) { private static void checkNewProxyPermission(Class<?> caller, Class<?> proxyClass) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
if (ReflectUtil.isNonPublicProxyClass(proxyClass)) { if (ReflectUtil.isNonPublicProxyClass(proxyClass)) {
@ -1076,6 +1081,7 @@ public class Proxy implements java.io.Serializable {
/** /**
* Returns the class loader for the given module. * Returns the class loader for the given module.
*/ */
@SuppressWarnings("removal")
private static ClassLoader getLoader(Module m) { private static ClassLoader getLoader(Module m) {
PrivilegedAction<ClassLoader> pa = m::getClassLoader; PrivilegedAction<ClassLoader> pa = m::getClassLoader;
return AccessController.doPrivileged(pa); return AccessController.doPrivileged(pa);
@ -1113,6 +1119,7 @@ public class Proxy implements java.io.Serializable {
* s.checkPackageAccess()} denies access to the invocation * s.checkPackageAccess()} denies access to the invocation
* handler's class. * handler's class.
*/ */
@SuppressWarnings("removal")
@CallerSensitive @CallerSensitive
public static InvocationHandler getInvocationHandler(Object proxy) public static InvocationHandler getInvocationHandler(Object proxy)
throws IllegalArgumentException throws IllegalArgumentException
@ -1286,6 +1293,7 @@ public class Proxy implements java.io.Serializable {
* *
* @return a lookup for proxy class of this proxy instance * @return a lookup for proxy class of this proxy instance
*/ */
@SuppressWarnings("removal")
private static MethodHandles.Lookup proxyClassLookup(MethodHandles.Lookup caller, Class<?> proxyClass) { private static MethodHandles.Lookup proxyClassLookup(MethodHandles.Lookup caller, Class<?> proxyClass) {
return AccessController.doPrivileged(new PrivilegedAction<>() { return AccessController.doPrivileged(new PrivilegedAction<>() {
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -92,6 +92,7 @@ final class ProxyGenerator extends ClassWriter {
/** /**
* debugging flag for saving generated class files * debugging flag for saving generated class files
*/ */
@SuppressWarnings("removal")
private static final boolean saveGeneratedFiles = private static final boolean saveGeneratedFiles =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new GetBooleanAction( new GetBooleanAction(
@ -168,6 +169,7 @@ final class ProxyGenerator extends ClassWriter {
* @param interfaces proxy interfaces * @param interfaces proxy interfaces
* @param accessFlags access flags of the proxy class * @param accessFlags access flags of the proxy class
*/ */
@SuppressWarnings("removal")
static byte[] generateProxyClass(ClassLoader loader, static byte[] generateProxyClass(ClassLoader loader,
final String name, final String name,
List<Class<?>> interfaces, List<Class<?>> interfaces,

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -76,6 +76,7 @@ public class ObjectMethods {
MethodHandles.Lookup publicLookup = MethodHandles.publicLookup(); MethodHandles.Lookup publicLookup = MethodHandles.publicLookup();
MethodHandles.Lookup lookup = MethodHandles.lookup(); MethodHandles.Lookup lookup = MethodHandles.lookup();
@SuppressWarnings("removal")
ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
@Override public ClassLoader run() { return ClassLoader.getPlatformClassLoader(); } @Override public ClassLoader run() { return ClassLoader.getPlatformClassLoader(); }
}); });

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -585,6 +585,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
/** /**
* Gets an InputStream for this socket. * Gets an InputStream for this socket.
*/ */
@SuppressWarnings("removal")
protected synchronized InputStream getInputStream() throws IOException { protected synchronized InputStream getInputStream() throws IOException {
synchronized (fdLock) { synchronized (fdLock) {
if (isClosedOrPending()) if (isClosedOrPending())
@ -610,6 +611,7 @@ abstract class AbstractPlainSocketImpl extends SocketImpl implements PlatformSoc
/** /**
* Gets an OutputStream for this socket. * Gets an OutputStream for this socket.
*/ */
@SuppressWarnings("removal")
protected synchronized OutputStream getOutputStream() throws IOException { protected synchronized OutputStream getOutputStream() throws IOException {
synchronized (fdLock) { synchronized (fdLock) {
if (isClosedOrPending()) if (isClosedOrPending())

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -128,6 +128,7 @@ class Authenticator {
* @see java.net.NetPermission * @see java.net.NetPermission
*/ */
public static synchronized void setDefault(Authenticator a) { public static synchronized void setDefault(Authenticator a) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission setDefaultPermission NetPermission setDefaultPermission
@ -158,6 +159,7 @@ class Authenticator {
* @see java.net.NetPermission * @see java.net.NetPermission
*/ */
public static Authenticator getDefault() { public static Authenticator getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission requestPermission NetPermission requestPermission
@ -201,6 +203,7 @@ class Authenticator {
String prompt, String prompt,
String scheme) { String scheme) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission requestPermission NetPermission requestPermission
@ -263,6 +266,7 @@ class Authenticator {
String prompt, String prompt,
String scheme) { String scheme) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission requestPermission NetPermission requestPermission
@ -330,6 +334,7 @@ class Authenticator {
URL url, URL url,
RequestorType reqType) { RequestorType reqType) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission requestPermission NetPermission requestPermission
@ -403,6 +408,7 @@ class Authenticator {
URL url, URL url,
RequestorType reqType) { RequestorType reqType) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
NetPermission requestPermission NetPermission requestPermission

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -75,6 +75,7 @@ public abstract class CookieHandler {
* @see #setDefault(CookieHandler) * @see #setDefault(CookieHandler)
*/ */
public static synchronized CookieHandler getDefault() { public static synchronized CookieHandler getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_COOKIEHANDLER_PERMISSION); sm.checkPermission(SecurityConstants.GET_COOKIEHANDLER_PERMISSION);
@ -95,6 +96,7 @@ public abstract class CookieHandler {
* @see #getDefault() * @see #getDefault()
*/ */
public static synchronized void setDefault(CookieHandler cHandler) { public static synchronized void setDefault(CookieHandler cHandler) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.SET_COOKIEHANDLER_PERMISSION); sm.checkPermission(SecurityConstants.SET_COOKIEHANDLER_PERMISSION);

View File

@ -1151,6 +1151,7 @@ public class DatagramSocket implements java.io.Closeable {
if (factory != null) { if (factory != null) {
throw new SocketException("factory already defined"); throw new SocketException("factory already defined");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSetFactory(); security.checkSetFactory();
@ -1341,6 +1342,7 @@ public class DatagramSocket implements java.io.Closeable {
private static boolean usePlainDatagramSocketImpl() { private static boolean usePlainDatagramSocketImpl() {
PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainDatagramSocketImpl"); PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainDatagramSocketImpl");
@SuppressWarnings("removal")
String s = AccessController.doPrivileged(pa); String s = AccessController.doPrivileged(pa);
return (s != null) && (s.isEmpty() || s.equalsIgnoreCase("true")); return (s != null) && (s.isEmpty() || s.equalsIgnoreCase("true"));
} }

View File

@ -40,7 +40,7 @@ import java.util.Set;
* @since 1.8 * @since 1.8
*/ */
/*package*/ class HttpConnectSocketImpl extends DelegatingSocketImpl { /*package*/ @SuppressWarnings("removal") class HttpConnectSocketImpl extends DelegatingSocketImpl {
private static final String httpURLClazzStr = private static final String httpURLClazzStr =
"sun.net.www.protocol.http.HttpURLConnection"; "sun.net.www.protocol.http.HttpURLConnection";

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -388,6 +388,7 @@ public abstract class HttpURLConnection extends URLConnection {
* @see #getFollowRedirects() * @see #getFollowRedirects()
*/ */
public static void setFollowRedirects(boolean set) { public static void setFollowRedirects(boolean set) {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {
// seems to be the best check here... // seems to be the best check here...
@ -475,6 +476,7 @@ public abstract class HttpURLConnection extends URLConnection {
for (int i = 0; i < methods.length; i++) { for (int i = 0; i < methods.length; i++) {
if (methods[i].equals(method)) { if (methods[i].equals(method)) {
if (method.equals("TRACE")) { if (method.equals("TRACE")) {
@SuppressWarnings("removal")
SecurityManager s = System.getSecurityManager(); SecurityManager s = System.getSecurityManager();
if (s != null) { if (s != null) {
s.checkPermission(new NetPermission("allowHttpTrace")); s.checkPermission(new NetPermission("allowHttpTrace"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -72,6 +72,7 @@ import jdk.internal.icu.text.UCharacterIterator;
* @since 1.6 * @since 1.6
* *
*/ */
@SuppressWarnings("removal")
public final class IDN { public final class IDN {
/** /**
* Flag to allow processing of unassigned code points * Flag to allow processing of unassigned code points

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -665,6 +665,7 @@ public class InetAddress implements java.io.Serializable {
* the hostname for this IP address, ie, connect to the host * the hostname for this IP address, ie, connect to the host
*/ */
if (check) { if (check) {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {
sec.checkConnect(host, -1); sec.checkConnect(host, -1);
@ -1450,6 +1451,7 @@ public class InetAddress implements java.io.Serializable {
* give out a hostname * give out a hostname
*/ */
if (check) { if (check) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkConnect(host, -1); security.checkConnect(host, -1);
@ -1611,6 +1613,7 @@ public class InetAddress implements java.io.Serializable {
*/ */
public static InetAddress getLocalHost() throws UnknownHostException { public static InetAddress getLocalHost() throws UnknownHostException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
try { try {
// is cached data still valid? // is cached data still valid?

View File

@ -118,6 +118,7 @@ final class NetMulticastSocket extends MulticastSocket {
checkAddress(address, "connect"); checkAddress(address, "connect");
if (isClosed()) if (isClosed())
return; return;
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
if (address.isMulticastAddress()) { if (address.isMulticastAddress()) {
@ -168,6 +169,7 @@ final class NetMulticastSocket extends MulticastSocket {
* Return true if the given DatagramSocketImpl is an "old" impl. An old impl * Return true if the given DatagramSocketImpl is an "old" impl. An old impl
* is one that doesn't implement the abstract methods added in Java SE 1.4. * is one that doesn't implement the abstract methods added in Java SE 1.4.
*/ */
@SuppressWarnings("removal")
private static boolean checkOldImpl(DatagramSocketImpl impl) { private static boolean checkOldImpl(DatagramSocketImpl impl) {
// DatagramSocketImpl.peekData() is a protected method, therefore we need to use // DatagramSocketImpl.peekData() is a protected method, therefore we need to use
// getDeclaredMethod, therefore we need permission to access the member // getDeclaredMethod, therefore we need permission to access the member
@ -223,6 +225,7 @@ final class NetMulticastSocket extends MulticastSocket {
InetAddress iaddr = epoint.getAddress(); InetAddress iaddr = epoint.getAddress();
int port = epoint.getPort(); int port = epoint.getPort();
checkAddress(iaddr, "bind"); checkAddress(iaddr, "bind");
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {
sec.checkListen(port); sec.checkListen(port);
@ -331,6 +334,7 @@ final class NetMulticastSocket extends MulticastSocket {
if (packetPort < 0 || packetPort > 0xFFFF) if (packetPort < 0 || packetPort > 0xFFFF)
throw new IllegalArgumentException("port out of range: " + packetPort); throw new IllegalArgumentException("port out of range: " + packetPort);
// check the address is ok with the security manager on every send. // check the address is ok with the security manager on every send.
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
// The reason you want to synchronize on datagram packet // The reason you want to synchronize on datagram packet
@ -375,6 +379,7 @@ final class NetMulticastSocket extends MulticastSocket {
bind(new InetSocketAddress(0)); bind(new InetSocketAddress(0));
if (connectState == ST_NOT_CONNECTED) { if (connectState == ST_NOT_CONNECTED) {
// check the address is ok with the security manager before every recv. // check the address is ok with the security manager before every recv.
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
while (true) { while (true) {
@ -480,6 +485,7 @@ final class NetMulticastSocket extends MulticastSocket {
if (in.isAnyLocalAddress()) { if (in.isAnyLocalAddress()) {
in = InetAddress.anyLocalAddress(); in = InetAddress.anyLocalAddress();
} }
@SuppressWarnings("removal")
SecurityManager s = System.getSecurityManager(); SecurityManager s = System.getSecurityManager();
if (s != null) { if (s != null) {
s.checkConnect(in.getHostAddress(), -1); s.checkConnect(in.getHostAddress(), -1);
@ -751,6 +757,7 @@ final class NetMulticastSocket extends MulticastSocket {
} }
checkAddress(mcastaddr, "joinGroup"); checkAddress(mcastaddr, "joinGroup");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkMulticast(mcastaddr); security.checkMulticast(mcastaddr);
@ -781,6 +788,7 @@ final class NetMulticastSocket extends MulticastSocket {
} }
checkAddress(mcastaddr, "leaveGroup"); checkAddress(mcastaddr, "leaveGroup");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkMulticast(mcastaddr); security.checkMulticast(mcastaddr);
@ -806,6 +814,7 @@ final class NetMulticastSocket extends MulticastSocket {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
checkAddress(addr.getAddress(), "joinGroup"); checkAddress(addr.getAddress(), "joinGroup");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkMulticast(addr.getAddress()); security.checkMulticast(addr.getAddress());
@ -831,6 +840,7 @@ final class NetMulticastSocket extends MulticastSocket {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
checkAddress(addr.getAddress(), "leaveGroup"); checkAddress(addr.getAddress(), "leaveGroup");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkMulticast(addr.getAddress()); security.checkMulticast(addr.getAddress());
@ -945,6 +955,7 @@ final class NetMulticastSocket extends MulticastSocket {
return ((Boolean)getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP)).booleanValue(); return ((Boolean)getImpl().getOption(SocketOptions.IP_MULTICAST_LOOP)).booleanValue();
} }
@SuppressWarnings("removal")
@Deprecated @Deprecated
@Override @Override
public void send(DatagramPacket p, byte ttl) public void send(DatagramPacket p, byte ttl)

View File

@ -133,6 +133,7 @@ public final class NetworkInterface {
InetAddress[] local_addrs = new InetAddress[addrs.length]; InetAddress[] local_addrs = new InetAddress[addrs.length];
boolean trusted = true; boolean trusted = true;
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {
try { try {
@ -169,6 +170,7 @@ public final class NetworkInterface {
public java.util.List<InterfaceAddress> getInterfaceAddresses() { public java.util.List<InterfaceAddress> getInterfaceAddresses() {
java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1); java.util.List<InterfaceAddress> lst = new java.util.ArrayList<>(1);
if (bindings != null) { if (bindings != null) {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
for (int j=0; j<bindings.length; j++) { for (int j=0; j<bindings.length; j++) {
try { try {
@ -512,6 +514,7 @@ public final class NetworkInterface {
* @since 1.6 * @since 1.6
*/ */
public byte[] getHardwareAddress() throws SocketException { public byte[] getHardwareAddress() throws SocketException {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager(); SecurityManager sec = System.getSecurityManager();
if (sec != null) { if (sec != null) {
try { try {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -96,6 +96,7 @@ public abstract class ProxySelector {
* @since 1.5 * @since 1.5
*/ */
public static ProxySelector getDefault() { public static ProxySelector getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION); sm.checkPermission(SecurityConstants.GET_PROXYSELECTOR_PERMISSION);
@ -119,6 +120,7 @@ public abstract class ProxySelector {
* @since 1.5 * @since 1.5
*/ */
public static void setDefault(ProxySelector ps) { public static void setDefault(ProxySelector ps) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.SET_PROXYSELECTOR_PERMISSION); sm.checkPermission(SecurityConstants.SET_PROXYSELECTOR_PERMISSION);

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -86,6 +86,7 @@ public abstract class ResponseCache {
* @since 1.5 * @since 1.5
*/ */
public static synchronized ResponseCache getDefault() { public static synchronized ResponseCache getDefault() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.GET_RESPONSECACHE_PERMISSION); sm.checkPermission(SecurityConstants.GET_RESPONSECACHE_PERMISSION);
@ -109,6 +110,7 @@ public abstract class ResponseCache {
* @since 1.5 * @since 1.5
*/ */
public static synchronized void setDefault(ResponseCache responseCache) { public static synchronized void setDefault(ResponseCache responseCache) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.SET_RESPONSECACHE_PERMISSION); sm.checkPermission(SecurityConstants.SET_RESPONSECACHE_PERMISSION);

View File

@ -109,6 +109,7 @@ public class ServerSocket implements java.io.Closeable {
} }
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION); sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
@ -380,6 +381,7 @@ public class ServerSocket implements java.io.Closeable {
if (backlog < 1) if (backlog < 1)
backlog = 50; backlog = 50;
try { try {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) if (security != null)
security.checkListen(epoint.getPort()); security.checkListen(epoint.getPort());
@ -418,6 +420,7 @@ public class ServerSocket implements java.io.Closeable {
return null; return null;
try { try {
InetAddress in = getImpl().getInetAddress(); InetAddress in = getImpl().getInetAddress();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkConnect(in.getHostAddress(), -1); sm.checkConnect(in.getHostAddress(), -1);
@ -672,6 +675,7 @@ public class ServerSocket implements java.io.Closeable {
impl.accept(si); impl.accept(si);
// check permission, close SocketImpl/connection if denied // check permission, close SocketImpl/connection if denied
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
try { try {
@ -879,6 +883,7 @@ public class ServerSocket implements java.io.Closeable {
* *
* @return a string representation of this socket. * @return a string representation of this socket.
*/ */
@SuppressWarnings("removal")
public String toString() { public String toString() {
if (!isBound()) if (!isBound())
return "ServerSocket[unbound]"; return "ServerSocket[unbound]";
@ -935,6 +940,7 @@ public class ServerSocket implements java.io.Closeable {
if (factory != null) { if (factory != null) {
throw new SocketException("factory already defined"); throw new SocketException("factory already defined");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSetFactory(); security.checkSetFactory();

View File

@ -180,6 +180,7 @@ public class Socket implements java.io.Closeable {
: sun.net.ApplicationProxy.create(proxy); : sun.net.ApplicationProxy.create(proxy);
Proxy.Type type = p.type(); Proxy.Type type = p.type();
if (type == Proxy.Type.SOCKS || type == Proxy.Type.HTTP) { if (type == Proxy.Type.SOCKS || type == Proxy.Type.HTTP) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
InetSocketAddress epoint = (InetSocketAddress) p.address(); InetSocketAddress epoint = (InetSocketAddress) p.address();
if (epoint.getAddress() != null) { if (epoint.getAddress() != null) {
@ -237,6 +238,7 @@ public class Socket implements java.io.Closeable {
if (impl == null) { if (impl == null) {
return null; return null;
} }
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION); sm.checkPermission(SecurityConstants.SET_SOCKETIMPL_PERMISSION);
@ -618,6 +620,7 @@ public class Socket implements java.io.Closeable {
int port = epoint.getPort(); int port = epoint.getPort();
checkAddress(addr, "connect"); checkAddress(addr, "connect");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
if (epoint.isUnresolved()) if (epoint.isUnresolved())
@ -671,6 +674,7 @@ public class Socket implements java.io.Closeable {
InetAddress addr = epoint.getAddress(); InetAddress addr = epoint.getAddress();
int port = epoint.getPort(); int port = epoint.getPort();
checkAddress (addr, "bind"); checkAddress (addr, "bind");
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkListen(port); security.checkListen(port);
@ -739,6 +743,7 @@ public class Socket implements java.io.Closeable {
InetAddress in = null; InetAddress in = null;
try { try {
in = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR); in = (InetAddress) getImpl().getOption(SocketOptions.SO_BINDADDR);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkConnect(in.getHostAddress(), -1); sm.checkConnect(in.getHostAddress(), -1);
@ -1763,6 +1768,7 @@ public class Socket implements java.io.Closeable {
if (factory != null) { if (factory != null) {
throw new SocketException("factory already defined"); throw new SocketException("factory already defined");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSetFactory(); security.checkSetFactory();

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -67,6 +67,7 @@ public abstract class SocketImpl implements SocketOptions {
private static boolean usePlainSocketImpl() { private static boolean usePlainSocketImpl() {
PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainSocketImpl"); PrivilegedAction<String> pa = () -> NetProperties.get("jdk.net.usePlainSocketImpl");
@SuppressWarnings("removal")
String s = AccessController.doPrivileged(pa); String s = AccessController.doPrivileged(pa);
return (s != null) && !s.equalsIgnoreCase("false"); return (s != null) && !s.equalsIgnoreCase("false");
} }

View File

@ -245,6 +245,7 @@ public final class SocketPermission extends Permission
}; };
static { static {
@SuppressWarnings("removal")
Boolean tmp = java.security.AccessController.doPrivileged( Boolean tmp = java.security.AccessController.doPrivileged(
new sun.security.action.GetBooleanAction("sun.net.trustNameService")); new sun.security.action.GetBooleanAction("sun.net.trustNameService"));
trustNameService = tmp.booleanValue(); trustNameService = tmp.booleanValue();
@ -1224,6 +1225,7 @@ public final class SocketPermission extends Permission
* Check the system/security property for the ephemeral port range * Check the system/security property for the ephemeral port range
* for this system. The suffix is either "high" or "low" * for this system. The suffix is either "high" or "low"
*/ */
@SuppressWarnings("removal")
private static int initEphemeralPorts(String suffix, int defval) { private static int initEphemeralPorts(String suffix, int defval) {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<>(){ new PrivilegedAction<>(){

View File

@ -73,6 +73,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
return DefaultProxySelector.socksProxyVersion() == 4; return DefaultProxySelector.socksProxyVersion() == 4;
} }
@SuppressWarnings("removal")
private synchronized void privilegedConnect(final String host, private synchronized void privilegedConnect(final String host,
final int port, final int port,
final int timeout) final int timeout)
@ -148,6 +149,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
String userName; String userName;
String password = null; String password = null;
final InetAddress addr = InetAddress.getByName(server); final InetAddress addr = InetAddress.getByName(server);
@SuppressWarnings("removal")
PasswordAuthentication pw = PasswordAuthentication pw =
java.security.AccessController.doPrivileged( java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() { new java.security.PrivilegedAction<>() {
@ -270,6 +272,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
deadlineMillis = finish < 0 ? Long.MAX_VALUE : finish; deadlineMillis = finish < 0 ? Long.MAX_VALUE : finish;
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (!(endpoint instanceof InetSocketAddress epoint)) if (!(endpoint instanceof InetSocketAddress epoint))
throw new IllegalArgumentException("Unsupported address type"); throw new IllegalArgumentException("Unsupported address type");
@ -285,6 +288,7 @@ class SocksSocketImpl extends DelegatingSocketImpl implements SocksConsts {
// This is the general case // This is the general case
// server is not null only when the socket was created with a // server is not null only when the socket was created with a
// specified proxy in which case it does bypass the ProxySelector // specified proxy in which case it does bypass the ProxySelector
@SuppressWarnings("removal")
ProxySelector sel = java.security.AccessController.doPrivileged( ProxySelector sel = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<>() { new java.security.PrivilegedAction<>() {
public ProxySelector run() { public ProxySelector run() {

View File

@ -431,6 +431,7 @@ public final class URL implements java.io.Serializable {
public URL(String protocol, String host, int port, String file, public URL(String protocol, String host, int port, String file,
URLStreamHandler handler) throws MalformedURLException { URLStreamHandler handler) throws MalformedURLException {
if (handler != null) { if (handler != null) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
// check for permission to specify a handler // check for permission to specify a handler
@ -602,6 +603,7 @@ public final class URL implements java.io.Serializable {
// Check for permission to specify a handler // Check for permission to specify a handler
if (handler != null) { if (handler != null) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
checkSpecifyHandler(sm); checkSpecifyHandler(sm);
@ -770,7 +772,7 @@ public final class URL implements java.io.Serializable {
/* /*
* Checks for permission to specify a stream handler. * Checks for permission to specify a stream handler.
*/ */
private void checkSpecifyHandler(SecurityManager sm) { private void checkSpecifyHandler(@SuppressWarnings("removal") SecurityManager sm) {
sm.checkPermission(SecurityConstants.SPECIFY_HANDLER_PERMISSION); sm.checkPermission(SecurityConstants.SPECIFY_HANDLER_PERMISSION);
} }
@ -1129,6 +1131,7 @@ public final class URL implements java.io.Serializable {
// Create a copy of Proxy as a security measure // Create a copy of Proxy as a security measure
Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy); Proxy p = proxy == Proxy.NO_PROXY ? Proxy.NO_PROXY : sun.net.ApplicationProxy.create(proxy);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (p.type() != Proxy.Type.DIRECT && sm != null) { if (p.type() != Proxy.Type.DIRECT && sm != null) {
InetSocketAddress epoint = (InetSocketAddress) p.address(); InetSocketAddress epoint = (InetSocketAddress) p.address();
@ -1224,6 +1227,7 @@ public final class URL implements java.io.Serializable {
if (factory != null) { if (factory != null) {
throw new Error("factory already defined"); throw new Error("factory already defined");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSetFactory(); security.checkSetFactory();
@ -1341,6 +1345,7 @@ public final class URL implements java.io.Serializable {
// Thread-local gate to prevent recursive provider lookups // Thread-local gate to prevent recursive provider lookups
private static ThreadLocal<Object> gate = new ThreadLocal<>(); private static ThreadLocal<Object> gate = new ThreadLocal<>();
@SuppressWarnings("removal")
private static URLStreamHandler lookupViaProviders(final String protocol) { private static URLStreamHandler lookupViaProviders(final String protocol) {
if (gate.get() != null) if (gate.get() != null)
throw new Error("Circular loading of URL stream handler providers detected"); throw new Error("Circular loading of URL stream handler providers detected");

View File

@ -84,6 +84,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
private final URLClassPath ucp; private final URLClassPath ucp;
/* The context to be used when loading classes and resources */ /* The context to be used when loading classes and resources */
@SuppressWarnings("removal")
private final AccessControlContext acc; private final AccessControlContext acc;
/** /**
@ -108,6 +109,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* elements is {@code null}. * elements is {@code null}.
* @see SecurityManager#checkCreateClassLoader * @see SecurityManager#checkCreateClassLoader
*/ */
@SuppressWarnings("removal")
public URLClassLoader(URL[] urls, ClassLoader parent) { public URLClassLoader(URL[] urls, ClassLoader parent) {
super(parent); super(parent);
this.acc = AccessController.getContext(); this.acc = AccessController.getContext();
@ -115,7 +117,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
} }
URLClassLoader(String name, URL[] urls, ClassLoader parent, URLClassLoader(String name, URL[] urls, ClassLoader parent,
AccessControlContext acc) { @SuppressWarnings("removal") AccessControlContext acc) {
super(name, parent); super(name, parent);
this.acc = acc; this.acc = acc;
this.ucp = new URLClassPath(urls, acc); this.ucp = new URLClassPath(urls, acc);
@ -143,13 +145,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* elements is {@code null}. * elements is {@code null}.
* @see SecurityManager#checkCreateClassLoader * @see SecurityManager#checkCreateClassLoader
*/ */
@SuppressWarnings("removal")
public URLClassLoader(URL[] urls) { public URLClassLoader(URL[] urls) {
super(); super();
this.acc = AccessController.getContext(); this.acc = AccessController.getContext();
this.ucp = new URLClassPath(urls, acc); this.ucp = new URLClassPath(urls, acc);
} }
URLClassLoader(URL[] urls, AccessControlContext acc) { URLClassLoader(URL[] urls, @SuppressWarnings("removal") AccessControlContext acc) {
super(); super();
this.acc = acc; this.acc = acc;
this.ucp = new URLClassPath(urls, acc); this.ucp = new URLClassPath(urls, acc);
@ -177,6 +180,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* elements is {@code null}. * elements is {@code null}.
* @see SecurityManager#checkCreateClassLoader * @see SecurityManager#checkCreateClassLoader
*/ */
@SuppressWarnings("removal")
public URLClassLoader(URL[] urls, ClassLoader parent, public URLClassLoader(URL[] urls, ClassLoader parent,
URLStreamHandlerFactory factory) { URLStreamHandlerFactory factory) {
super(parent); super(parent);
@ -207,6 +211,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* *
* @since 9 * @since 9
*/ */
@SuppressWarnings("removal")
public URLClassLoader(String name, public URLClassLoader(String name,
URL[] urls, URL[] urls,
ClassLoader parent) { ClassLoader parent) {
@ -237,6 +242,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* *
* @since 9 * @since 9
*/ */
@SuppressWarnings("removal")
public URLClassLoader(String name, URL[] urls, ClassLoader parent, public URLClassLoader(String name, URL[] urls, ClassLoader parent,
URLStreamHandlerFactory factory) { URLStreamHandlerFactory factory) {
super(name, parent); super(name, parent);
@ -335,6 +341,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* @since 1.7 * @since 1.7
*/ */
public void close() throws IOException { public void close() throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkPermission(new RuntimePermission("closeClassLoader")); security.checkPermission(new RuntimePermission("closeClassLoader"));
@ -404,6 +411,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* or if the loader is closed. * or if the loader is closed.
* @throws NullPointerException if {@code name} is {@code null}. * @throws NullPointerException if {@code name} is {@code null}.
*/ */
@SuppressWarnings("removal")
protected Class<?> findClass(final String name) protected Class<?> findClass(final String name)
throws ClassNotFoundException throws ClassNotFoundException
{ {
@ -609,6 +617,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
/* /*
* The same restriction to finding classes applies to resources * The same restriction to finding classes applies to resources
*/ */
@SuppressWarnings("removal")
URL url = AccessController.doPrivileged( URL url = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
public URL run() { public URL run() {
@ -641,6 +650,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
return true; return true;
} }
do { do {
@SuppressWarnings("removal")
URL u = AccessController.doPrivileged( URL u = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
public URL run() { public URL run() {
@ -695,6 +705,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
* @throws NullPointerException if {@code codesource} is {@code null}. * @throws NullPointerException if {@code codesource} is {@code null}.
* @return the permissions granted to the codesource * @return the permissions granted to the codesource
*/ */
@SuppressWarnings("removal")
protected PermissionCollection getPermissions(CodeSource codesource) protected PermissionCollection getPermissions(CodeSource codesource)
{ {
PermissionCollection perms = super.getPermissions(codesource); PermissionCollection perms = super.getPermissions(codesource);
@ -779,8 +790,10 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
public static URLClassLoader newInstance(final URL[] urls, public static URLClassLoader newInstance(final URL[] urls,
final ClassLoader parent) { final ClassLoader parent) {
// Save the caller's context // Save the caller's context
@SuppressWarnings("removal")
final AccessControlContext acc = AccessController.getContext(); final AccessControlContext acc = AccessController.getContext();
// Need a privileged block to create the class loader // Need a privileged block to create the class loader
@SuppressWarnings("removal")
URLClassLoader ucl = AccessController.doPrivileged( URLClassLoader ucl = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
public URLClassLoader run() { public URLClassLoader run() {
@ -805,8 +818,10 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
*/ */
public static URLClassLoader newInstance(final URL[] urls) { public static URLClassLoader newInstance(final URL[] urls) {
// Save the caller's context // Save the caller's context
@SuppressWarnings("removal")
final AccessControlContext acc = AccessController.getContext(); final AccessControlContext acc = AccessController.getContext();
// Need a privileged block to create the class loader // Need a privileged block to create the class loader
@SuppressWarnings("removal")
URLClassLoader ucl = AccessController.doPrivileged( URLClassLoader ucl = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
public URLClassLoader run() { public URLClassLoader run() {
@ -828,11 +843,11 @@ final class FactoryURLClassLoader extends URLClassLoader {
} }
FactoryURLClassLoader(String name, URL[] urls, ClassLoader parent, FactoryURLClassLoader(String name, URL[] urls, ClassLoader parent,
AccessControlContext acc) { @SuppressWarnings("removal") AccessControlContext acc) {
super(name, urls, parent, acc); super(name, urls, parent, acc);
} }
FactoryURLClassLoader(URL[] urls, AccessControlContext acc) { FactoryURLClassLoader(URL[] urls, @SuppressWarnings("removal") AccessControlContext acc) {
super(urls, acc); super(urls, acc);
} }
@ -841,6 +856,7 @@ final class FactoryURLClassLoader extends URLClassLoader {
{ {
// First check if we have permission to access the package. This // First check if we have permission to access the package. This
// should go away once we've added support for exported packages. // should go away once we've added support for exported packages.
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
int i = name.lastIndexOf('.'); int i = name.lastIndexOf('.');

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1995, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -334,6 +334,7 @@ public abstract class URLConnection {
* @since 1.2 * @since 1.2
*/ */
public static void setFileNameMap(FileNameMap map) { public static void setFileNameMap(FileNameMap map) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkSetFactory(); if (sm != null) sm.checkSetFactory();
fileNameMap = map; fileNameMap = map;
@ -1264,6 +1265,7 @@ public abstract class URLConnection {
if (factory != null) { if (factory != null) {
throw new Error("factory already defined"); throw new Error("factory already defined");
} }
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSetFactory(); security.checkSetFactory();
@ -1377,6 +1379,7 @@ public abstract class URLConnection {
return UnknownContentHandler.INSTANCE; return UnknownContentHandler.INSTANCE;
} }
@SuppressWarnings("removal")
private ContentHandler lookupContentHandlerViaProvider(String contentType) { private ContentHandler lookupContentHandlerViaProvider(String contentType) {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,7 @@ public abstract class URLStreamHandlerProvider
implements URLStreamHandlerFactory implements URLStreamHandlerFactory
{ {
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("setFactory")); sm.checkPermission(new RuntimePermission("setFactory"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -52,6 +52,7 @@ import java.security.PrivilegedAction;
public abstract class AsynchronousChannelProvider { public abstract class AsynchronousChannelProvider {
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("asynchronousChannelProvider")); sm.checkPermission(new RuntimePermission("asynchronousChannelProvider"));
@ -74,6 +75,7 @@ public abstract class AsynchronousChannelProvider {
private static class ProviderHolder { private static class ProviderHolder {
static final AsynchronousChannelProvider provider = load(); static final AsynchronousChannelProvider provider = load();
@SuppressWarnings("removal")
private static AsynchronousChannelProvider load() { private static AsynchronousChannelProvider load() {
return AccessController return AccessController
.doPrivileged(new PrivilegedAction<>() { .doPrivileged(new PrivilegedAction<>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,7 @@ import java.util.ServiceConfigurationError;
public abstract class SelectorProvider { public abstract class SelectorProvider {
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("selectorProvider")); sm.checkPermission(new RuntimePermission("selectorProvider"));
@ -94,6 +95,7 @@ public abstract class SelectorProvider {
private static class Holder { private static class Holder {
static final SelectorProvider INSTANCE = provider(); static final SelectorProvider INSTANCE = provider();
@SuppressWarnings("removal")
static SelectorProvider provider() { static SelectorProvider provider() {
PrivilegedAction<SelectorProvider> pa = () -> { PrivilegedAction<SelectorProvider> pa = () -> {
SelectorProvider sp; SelectorProvider sp;

View File

@ -375,6 +375,7 @@ public abstract class Charset
private static ThreadLocal<ThreadLocal<?>> gate = private static ThreadLocal<ThreadLocal<?>> gate =
new ThreadLocal<ThreadLocal<?>>(); new ThreadLocal<ThreadLocal<?>>();
@SuppressWarnings("removal")
private static Charset lookupViaProviders(final String charsetName) { private static Charset lookupViaProviders(final String charsetName) {
// The runtime startup sequence looks up standard charsets as a // The runtime startup sequence looks up standard charsets as a
@ -417,6 +418,7 @@ public abstract class Charset
private static class ExtendedProviderHolder { private static class ExtendedProviderHolder {
static final CharsetProvider[] extendedProviders = extendedProviders(); static final CharsetProvider[] extendedProviders = extendedProviders();
// returns ExtendedProvider, if installed // returns ExtendedProvider, if installed
@SuppressWarnings("removal")
private static CharsetProvider[] extendedProviders() { private static CharsetProvider[] extendedProviders() {
return AccessController.doPrivileged(new PrivilegedAction<>() { return AccessController.doPrivileged(new PrivilegedAction<>() {
public CharsetProvider[] run() { public CharsetProvider[] run() {
@ -563,6 +565,7 @@ public abstract class Charset
* @return An immutable, case-insensitive map from canonical charset names * @return An immutable, case-insensitive map from canonical charset names
* to charset objects * to charset objects
*/ */
@SuppressWarnings("removal")
public static SortedMap<String,Charset> availableCharsets() { public static SortedMap<String,Charset> availableCharsets() {
return AccessController.doPrivileged( return AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -71,6 +71,7 @@ import java.util.Iterator;
public abstract class CharsetProvider { public abstract class CharsetProvider {
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("charsetProvider")); sm.checkPermission(new RuntimePermission("charsetProvider"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -96,6 +96,7 @@ public final class FileSystems {
// returns default file system // returns default file system
private static FileSystem defaultFileSystem() { private static FileSystem defaultFileSystem() {
// load default provider // load default provider
@SuppressWarnings("removal")
FileSystemProvider provider = AccessController FileSystemProvider provider = AccessController
.doPrivileged(new PrivilegedAction<>() { .doPrivileged(new PrivilegedAction<>() {
public FileSystemProvider run() { public FileSystemProvider run() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -198,6 +198,7 @@ class FileTreeWalker implements Closeable {
* the walk is following sym links is not. The {@code canUseCached} * the walk is following sym links is not. The {@code canUseCached}
* argument determines whether this method can use cached attributes. * argument determines whether this method can use cached attributes.
*/ */
@SuppressWarnings("removal")
private BasicFileAttributes getAttributes(Path file, boolean canUseCached) private BasicFileAttributes getAttributes(Path file, boolean canUseCached)
throws IOException throws IOException
{ {

View File

@ -1651,6 +1651,7 @@ public final class Files {
loadInstalledDetectors(); loadInstalledDetectors();
// creates the default file type detector // creates the default file type detector
@SuppressWarnings("removal")
private static FileTypeDetector createDefaultFileTypeDetector() { private static FileTypeDetector createDefaultFileTypeDetector() {
return AccessController return AccessController
.doPrivileged(new PrivilegedAction<>() { .doPrivileged(new PrivilegedAction<>() {
@ -1660,6 +1661,7 @@ public final class Files {
} }
// loads all installed file type detectors // loads all installed file type detectors
@SuppressWarnings("removal")
private static List<FileTypeDetector> loadInstalledDetectors() { private static List<FileTypeDetector> loadInstalledDetectors() {
return AccessController return AccessController
.doPrivileged(new PrivilegedAction<>() { .doPrivileged(new PrivilegedAction<>() {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -117,6 +117,7 @@ class TempFileHelper {
} }
// loop generating random names until file or directory can be created // loop generating random names until file or directory can be created
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
for (;;) { for (;;) {
Path f; Path f;

View File

@ -121,6 +121,7 @@ public abstract class FileSystemProvider {
private static boolean loadingProviders = false; private static boolean loadingProviders = false;
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("fileSystemProvider")); sm.checkPermission(new RuntimePermission("fileSystemProvider"));
@ -198,6 +199,7 @@ public abstract class FileSystemProvider {
} }
loadingProviders = true; loadingProviders = true;
@SuppressWarnings("removal")
List<FileSystemProvider> list = AccessController List<FileSystemProvider> list = AccessController
.doPrivileged(new PrivilegedAction<>() { .doPrivileged(new PrivilegedAction<>() {
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -50,6 +50,7 @@ import java.io.IOException;
public abstract class FileTypeDetector { public abstract class FileTypeDetector {
private static Void checkPermission() { private static Void checkPermission() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(new RuntimePermission("fileTypeDetector")); sm.checkPermission(new RuntimePermission("fileTypeDetector"));

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -75,8 +75,14 @@ import sun.security.util.SecurityConstants;
* *
* @author Roland Schemers * @author Roland Schemers
* @since 1.2 * @since 1.2
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public final class AccessControlContext { public final class AccessControlContext {
private ProtectionDomain[] context; private ProtectionDomain[] context;
@ -89,6 +95,7 @@ public final class AccessControlContext {
// native codes. Don't touch it. // native codes. Don't touch it.
private AccessControlContext privilegedContext; private AccessControlContext privilegedContext;
@SuppressWarnings("removal")
private DomainCombiner combiner = null; private DomainCombiner combiner = null;
// limited privilege scope // limited privilege scope
@ -103,6 +110,7 @@ public final class AccessControlContext {
private static boolean debugInit = false; private static boolean debugInit = false;
private static Debug debug = null; private static Debug debug = null;
@SuppressWarnings("removal")
static Debug getDebug() static Debug getDebug()
{ {
if (debugInit) if (debugInit)
@ -171,7 +179,7 @@ public final class AccessControlContext {
* @since 1.3 * @since 1.3
*/ */
public AccessControlContext(AccessControlContext acc, public AccessControlContext(AccessControlContext acc,
DomainCombiner combiner) { @SuppressWarnings("removal") DomainCombiner combiner) {
this(acc, combiner, false); this(acc, combiner, false);
} }
@ -182,9 +190,10 @@ public final class AccessControlContext {
* permission * permission
*/ */
AccessControlContext(AccessControlContext acc, AccessControlContext(AccessControlContext acc,
DomainCombiner combiner, @SuppressWarnings("removal") DomainCombiner combiner,
boolean preauthorized) { boolean preauthorized) {
if (!preauthorized) { if (!preauthorized) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(SecurityConstants.CREATE_ACC_PERMISSION); sm.checkPermission(SecurityConstants.CREATE_ACC_PERMISSION);
@ -211,7 +220,7 @@ public final class AccessControlContext {
* This "argument wrapper" context will be passed as the actual context * This "argument wrapper" context will be passed as the actual context
* parameter on an internal doPrivileged() call used in the implementation. * parameter on an internal doPrivileged() call used in the implementation.
*/ */
AccessControlContext(ProtectionDomain caller, DomainCombiner combiner, AccessControlContext(ProtectionDomain caller, @SuppressWarnings("removal") DomainCombiner combiner,
AccessControlContext parent, AccessControlContext context, AccessControlContext parent, AccessControlContext context,
Permission[] perms) Permission[] perms)
{ {
@ -323,6 +332,7 @@ public final class AccessControlContext {
/** /**
* get the assigned combiner from the privileged or inherited context * get the assigned combiner from the privileged or inherited context
*/ */
@SuppressWarnings("removal")
DomainCombiner getAssignedCombiner() { DomainCombiner getAssignedCombiner() {
AccessControlContext acc; AccessControlContext acc;
if (isPrivileged) { if (isPrivileged) {
@ -349,6 +359,7 @@ public final class AccessControlContext {
* {@link SecurityPermission} * {@link SecurityPermission}
* @since 1.3 * @since 1.3
*/ */
@SuppressWarnings("removal")
public DomainCombiner getDomainCombiner() { public DomainCombiner getDomainCombiner() {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
@ -361,6 +372,7 @@ public final class AccessControlContext {
/** /**
* package private for AccessController * package private for AccessController
*/ */
@SuppressWarnings("removal")
DomainCombiner getCombiner() { DomainCombiner getCombiner() {
return combiner; return combiner;
} }
@ -388,6 +400,7 @@ public final class AccessControlContext {
* context encapsulated by this object. * context encapsulated by this object.
* @throws NullPointerException if the permission to check for is null. * @throws NullPointerException if the permission to check for is null.
*/ */
@SuppressWarnings("removal")
public void checkPermission(Permission perm) public void checkPermission(Permission perm)
throws AccessControlException throws AccessControlException
{ {
@ -548,6 +561,7 @@ public final class AccessControlContext {
* The limited privilege scope can indirectly flow from the inherited * The limited privilege scope can indirectly flow from the inherited
* parent thread or an assigned context previously captured by getContext(). * parent thread or an assigned context previously captured by getContext().
*/ */
@SuppressWarnings("removal")
AccessControlContext optimize() { AccessControlContext optimize() {
// the assigned (privileged or inherited) context // the assigned (privileged or inherited) context
AccessControlContext acc; AccessControlContext acc;

View File

@ -39,8 +39,14 @@ package java.security;
* @author Li Gong * @author Li Gong
* @author Roland Schemers * @author Roland Schemers
* @since 1.2 * @since 1.2
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public class AccessControlException extends SecurityException { public class AccessControlException extends SecurityException {
@java.io.Serial @java.io.Serial

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -271,8 +271,14 @@ import jdk.internal.vm.annotation.ReservedStackAccess;
* @author Li Gong * @author Li Gong
* @author Roland Schemers * @author Roland Schemers
* @since 1.2 * @since 1.2
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public final class AccessController { public final class AccessController {
/** /**
@ -339,10 +345,12 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) { public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action) {
@SuppressWarnings("removal")
AccessControlContext acc = getStackAccessControlContext(); AccessControlContext acc = getStackAccessControlContext();
if (acc == null) { if (acc == null) {
return AccessController.doPrivileged(action); return AccessController.doPrivileged(action);
} }
@SuppressWarnings("removal")
DomainCombiner dc = acc.getAssignedCombiner(); DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, return AccessController.doPrivileged(action,
preserveCombiner(dc, Reflection.getCallerClass())); preserveCombiner(dc, Reflection.getCallerClass()));
@ -384,7 +392,7 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivileged(PrivilegedAction<T> action, public static <T> T doPrivileged(PrivilegedAction<T> action,
AccessControlContext context) @SuppressWarnings("removal") AccessControlContext context)
{ {
Class<?> caller = Reflection.getCallerClass(); Class<?> caller = Reflection.getCallerClass();
context = checkContext(context, caller); context = checkContext(context, caller);
@ -438,13 +446,16 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivileged(PrivilegedAction<T> action, public static <T> T doPrivileged(PrivilegedAction<T> action,
AccessControlContext context, Permission... perms) { @SuppressWarnings("removal") AccessControlContext context,
Permission... perms) {
@SuppressWarnings("removal")
AccessControlContext parent = getContext(); AccessControlContext parent = getContext();
if (perms == null) { if (perms == null) {
throw new NullPointerException("null permissions parameter"); throw new NullPointerException("null permissions parameter");
} }
Class<?> caller = Reflection.getCallerClass(); Class<?> caller = Reflection.getCallerClass();
@SuppressWarnings("removal")
DomainCombiner dc = (context == null) ? null : context.getCombiner(); DomainCombiner dc = (context == null) ? null : context.getCombiner();
return AccessController.doPrivileged(action, createWrapper(dc, return AccessController.doPrivileged(action, createWrapper(dc,
caller, parent, context, perms)); caller, parent, context, perms));
@ -501,9 +512,12 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action, public static <T> T doPrivilegedWithCombiner(PrivilegedAction<T> action,
AccessControlContext context, Permission... perms) { @SuppressWarnings("removal") AccessControlContext context,
Permission... perms) {
@SuppressWarnings("removal")
AccessControlContext parent = getContext(); AccessControlContext parent = getContext();
@SuppressWarnings("removal")
DomainCombiner dc = parent.getCombiner(); DomainCombiner dc = parent.getCombiner();
if (dc == null && context != null) { if (dc == null && context != null) {
dc = context.getCombiner(); dc = context.getCombiner();
@ -548,6 +562,7 @@ public final class AccessController {
doPrivileged(PrivilegedExceptionAction<T> action) doPrivileged(PrivilegedExceptionAction<T> action)
throws PrivilegedActionException throws PrivilegedActionException
{ {
@SuppressWarnings("removal")
AccessControlContext context = null; AccessControlContext context = null;
Class<?> caller = Reflection.getCallerClass(); Class<?> caller = Reflection.getCallerClass();
try { try {
@ -591,10 +606,12 @@ public final class AccessController {
public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action) public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action)
throws PrivilegedActionException throws PrivilegedActionException
{ {
@SuppressWarnings("removal")
AccessControlContext acc = getStackAccessControlContext(); AccessControlContext acc = getStackAccessControlContext();
if (acc == null) { if (acc == null) {
return AccessController.doPrivileged(action); return AccessController.doPrivileged(action);
} }
@SuppressWarnings("removal")
DomainCombiner dc = acc.getAssignedCombiner(); DomainCombiner dc = acc.getAssignedCombiner();
return AccessController.doPrivileged(action, return AccessController.doPrivileged(action,
preserveCombiner(dc, Reflection.getCallerClass())); preserveCombiner(dc, Reflection.getCallerClass()));
@ -603,6 +620,7 @@ public final class AccessController {
/** /**
* preserve the combiner across the doPrivileged call * preserve the combiner across the doPrivileged call
*/ */
@SuppressWarnings("removal")
private static AccessControlContext preserveCombiner(DomainCombiner combiner, private static AccessControlContext preserveCombiner(DomainCombiner combiner,
Class<?> caller) Class<?> caller)
{ {
@ -612,6 +630,7 @@ public final class AccessController {
/** /**
* Create a wrapper to contain the limited privilege scope data. * Create a wrapper to contain the limited privilege scope data.
*/ */
@SuppressWarnings("removal")
private static AccessControlContext private static AccessControlContext
createWrapper(DomainCombiner combiner, Class<?> caller, createWrapper(DomainCombiner combiner, Class<?> caller,
AccessControlContext parent, AccessControlContext context, AccessControlContext parent, AccessControlContext context,
@ -633,10 +652,12 @@ public final class AccessController {
private static class AccHolder { private static class AccHolder {
// An AccessControlContext with no granted permissions. // An AccessControlContext with no granted permissions.
// Only initialized on demand when getInnocuousAcc() is called. // Only initialized on demand when getInnocuousAcc() is called.
@SuppressWarnings("removal")
static final AccessControlContext innocuousAcc = static final AccessControlContext innocuousAcc =
new AccessControlContext(new ProtectionDomain[] { new AccessControlContext(new ProtectionDomain[] {
new ProtectionDomain(null, null) }); new ProtectionDomain(null, null) });
} }
@SuppressWarnings("removal")
private static AccessControlContext getInnocuousAcc() { private static AccessControlContext getInnocuousAcc() {
return AccHolder.innocuousAcc; return AccHolder.innocuousAcc;
} }
@ -682,7 +703,7 @@ public final class AccessController {
@CallerSensitive @CallerSensitive
public static <T> T public static <T> T
doPrivileged(PrivilegedExceptionAction<T> action, doPrivileged(PrivilegedExceptionAction<T> action,
AccessControlContext context) @SuppressWarnings("removal") AccessControlContext context)
throws PrivilegedActionException throws PrivilegedActionException
{ {
Class<?> caller = Reflection.getCallerClass(); Class<?> caller = Reflection.getCallerClass();
@ -696,6 +717,7 @@ public final class AccessController {
} }
} }
@SuppressWarnings("removal")
private static AccessControlContext checkContext(AccessControlContext context, private static AccessControlContext checkContext(AccessControlContext context,
Class<?> caller) Class<?> caller)
{ {
@ -726,6 +748,7 @@ public final class AccessController {
* recognized by the VM. * recognized by the VM.
*/ */
private static boolean isPrivileged() { private static boolean isPrivileged() {
@SuppressWarnings("removal")
AccessControlContext ctx = getStackAccessControlContext(); AccessControlContext ctx = getStackAccessControlContext();
return ctx == null || ctx.isPrivileged(); return ctx == null || ctx.isPrivileged();
} }
@ -741,7 +764,7 @@ public final class AccessController {
@ForceInline @ForceInline
private static <T> T private static <T> T
executePrivileged(PrivilegedAction<T> action, executePrivileged(PrivilegedAction<T> action,
AccessControlContext context, @SuppressWarnings("removal") AccessControlContext context,
Class<?> caller) Class<?> caller)
{ {
// Ensure context has a physical value in the frame // Ensure context has a physical value in the frame
@ -771,7 +794,7 @@ public final class AccessController {
@ForceInline @ForceInline
private static <T> T private static <T> T
executePrivileged(PrivilegedExceptionAction<T> action, executePrivileged(PrivilegedExceptionAction<T> action,
AccessControlContext context, @SuppressWarnings("removal") AccessControlContext context,
Class<?> caller) Class<?> caller)
throws Exception throws Exception
{ {
@ -853,14 +876,17 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivileged(PrivilegedExceptionAction<T> action, public static <T> T doPrivileged(PrivilegedExceptionAction<T> action,
AccessControlContext context, Permission... perms) @SuppressWarnings("removal") AccessControlContext context,
Permission... perms)
throws PrivilegedActionException throws PrivilegedActionException
{ {
@SuppressWarnings("removal")
AccessControlContext parent = getContext(); AccessControlContext parent = getContext();
if (perms == null) { if (perms == null) {
throw new NullPointerException("null permissions parameter"); throw new NullPointerException("null permissions parameter");
} }
Class<?> caller = Reflection.getCallerClass(); Class<?> caller = Reflection.getCallerClass();
@SuppressWarnings("removal")
DomainCombiner dc = (context == null) ? null : context.getCombiner(); DomainCombiner dc = (context == null) ? null : context.getCombiner();
return AccessController.doPrivileged(action, createWrapper(dc, caller, parent, context, perms)); return AccessController.doPrivileged(action, createWrapper(dc, caller, parent, context, perms));
} }
@ -918,11 +944,13 @@ public final class AccessController {
*/ */
@CallerSensitive @CallerSensitive
public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action, public static <T> T doPrivilegedWithCombiner(PrivilegedExceptionAction<T> action,
AccessControlContext context, @SuppressWarnings("removal") AccessControlContext context,
Permission... perms) Permission... perms)
throws PrivilegedActionException throws PrivilegedActionException
{ {
@SuppressWarnings("removal")
AccessControlContext parent = getContext(); AccessControlContext parent = getContext();
@SuppressWarnings("removal")
DomainCombiner dc = parent.getCombiner(); DomainCombiner dc = parent.getCombiner();
if (dc == null && context != null) { if (dc == null && context != null) {
dc = context.getCombiner(); dc = context.getCombiner();
@ -945,6 +973,7 @@ public final class AccessController {
* null if there was only privileged system code. * null if there was only privileged system code.
*/ */
@SuppressWarnings("removal")
private static native AccessControlContext getStackAccessControlContext(); private static native AccessControlContext getStackAccessControlContext();
@ -954,6 +983,7 @@ public final class AccessController {
* AccessControlContext can use it. * AccessControlContext can use it.
*/ */
@SuppressWarnings("removal")
static native AccessControlContext getInheritedAccessControlContext(); static native AccessControlContext getInheritedAccessControlContext();
/** /**
@ -967,6 +997,7 @@ public final class AccessController {
* @return the AccessControlContext based on the current context. * @return the AccessControlContext based on the current context.
*/ */
@SuppressWarnings("removal")
public static AccessControlContext getContext() public static AccessControlContext getContext()
{ {
AccessControlContext acc = getStackAccessControlContext(); AccessControlContext acc = getStackAccessControlContext();
@ -997,6 +1028,7 @@ public final class AccessController {
* security policy currently in effect. * security policy currently in effect.
*/ */
@SuppressWarnings("removal")
public static void checkPermission(Permission perm) public static void checkPermission(Permission perm)
throws AccessControlException throws AccessControlException
{ {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -77,7 +77,13 @@ package java.security;
* @see AccessController * @see AccessController
* @see AccessControlContext * @see AccessControlContext
* @since 1.3 * @since 1.3
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public interface DomainCombiner { public interface DomainCombiner {
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -987,6 +987,7 @@ public class KeyStore {
* if no such property exists. * if no such property exists.
* @see java.security.Security security properties * @see java.security.Security security properties
*/ */
@SuppressWarnings("removal")
public static final String getDefaultType() { public static final String getDefaultType() {
String kstype; String kstype;
kstype = AccessController.doPrivileged(new PrivilegedAction<>() { kstype = AccessController.doPrivileged(new PrivilegedAction<>() {
@ -1956,6 +1957,7 @@ public class KeyStore {
* of either PasswordProtection or CallbackHandlerProtection; or * of either PasswordProtection or CallbackHandlerProtection; or
* if file does not exist or does not refer to a normal file * if file does not exist or does not refer to a normal file
*/ */
@SuppressWarnings("removal")
public static Builder newInstance(String type, Provider provider, public static Builder newInstance(String type, Provider provider,
File file, ProtectionParameter protection) { File file, ProtectionParameter protection) {
if ((type == null) || (file == null) || (protection == null)) { if ((type == null) || (file == null) || (protection == null)) {
@ -2027,6 +2029,7 @@ public class KeyStore {
private final File file; private final File file;
private ProtectionParameter protection; private ProtectionParameter protection;
private ProtectionParameter keyProtection; private ProtectionParameter keyProtection;
@SuppressWarnings("removal")
private final AccessControlContext context; private final AccessControlContext context;
private KeyStore keyStore; private KeyStore keyStore;
@ -2035,7 +2038,7 @@ public class KeyStore {
FileBuilder(String type, Provider provider, File file, FileBuilder(String type, Provider provider, File file,
ProtectionParameter protection, ProtectionParameter protection,
AccessControlContext context) { @SuppressWarnings("removal") AccessControlContext context) {
this.type = type; this.type = type;
this.provider = provider; this.provider = provider;
this.file = file; this.file = file;
@ -2043,6 +2046,7 @@ public class KeyStore {
this.context = context; this.context = context;
} }
@SuppressWarnings("removal")
public synchronized KeyStore getKeyStore() throws KeyStoreException public synchronized KeyStore getKeyStore() throws KeyStoreException
{ {
if (keyStore != null) { if (keyStore != null) {
@ -2174,6 +2178,7 @@ public class KeyStore {
if ((type == null) || (protection == null)) { if ((type == null) || (protection == null)) {
throw new NullPointerException(); throw new NullPointerException();
} }
@SuppressWarnings("removal")
final AccessControlContext context = AccessController.getContext(); final AccessControlContext context = AccessController.getContext();
return new Builder() { return new Builder() {
private volatile boolean getCalled; private volatile boolean getCalled;
@ -2218,6 +2223,7 @@ public class KeyStore {
} }
}; };
@SuppressWarnings("removal")
public synchronized KeyStore getKeyStore() public synchronized KeyStore getKeyStore()
throws KeyStoreException { throws KeyStoreException {
if (oldException != null) { if (oldException != null) {

View File

@ -103,6 +103,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
* *
*/ */
public void checkGuard(Object object) throws SecurityException { public void checkGuard(Object object) throws SecurityException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission(this); if (sm != null) sm.checkPermission(this);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -83,8 +83,14 @@ import sun.security.util.SecurityConstants;
* @see java.security.ProtectionDomain * @see java.security.ProtectionDomain
* @see java.security.Permission * @see java.security.Permission
* @see java.security.Security security properties * @see java.security.Security security properties
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public abstract class Policy { public abstract class Policy {
/** /**
@ -133,6 +139,7 @@ public abstract class Policy {
} }
private static void checkPermission(String type) { private static void checkPermission(String type) {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) { if (sm != null) {
sm.checkPermission(new SecurityPermission("createPolicy." + type)); sm.checkPermission(new SecurityPermission("createPolicy." + type));
@ -159,6 +166,7 @@ public abstract class Policy {
*/ */
public static Policy getPolicy() public static Policy getPolicy()
{ {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkPermission(SecurityConstants.GET_POLICY_PERMISSION); sm.checkPermission(SecurityConstants.GET_POLICY_PERMISSION);
@ -194,6 +202,7 @@ public abstract class Policy {
* an intrinsic lock on the Policy.class. * an intrinsic lock on the Policy.class.
*/ */
private static Policy loadPolicyProvider() { private static Policy loadPolicyProvider() {
@SuppressWarnings("removal")
String policyProvider = String policyProvider =
AccessController.doPrivileged(new PrivilegedAction<>() { AccessController.doPrivileged(new PrivilegedAction<>() {
@Override @Override
@ -222,6 +231,7 @@ public abstract class Policy {
Policy polFile = new sun.security.provider.PolicyFile(); Policy polFile = new sun.security.provider.PolicyFile();
policyInfo = new PolicyInfo(polFile, false); policyInfo = new PolicyInfo(polFile, false);
@SuppressWarnings("removal")
Policy pol = AccessController.doPrivileged(new PrivilegedAction<>() { Policy pol = AccessController.doPrivileged(new PrivilegedAction<>() {
@Override @Override
public Policy run() { public Policy run() {
@ -271,6 +281,7 @@ public abstract class Policy {
*/ */
public static void setPolicy(Policy p) public static void setPolicy(Policy p)
{ {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) sm.checkPermission( if (sm != null) sm.checkPermission(
new SecurityPermission("setPolicy")); new SecurityPermission("setPolicy"));
@ -310,6 +321,7 @@ public abstract class Policy {
* implementations will continue to function. * implementations will continue to function.
*/ */
@SuppressWarnings("removal")
ProtectionDomain policyDomain = ProtectionDomain policyDomain =
AccessController.doPrivileged(new PrivilegedAction<>() { AccessController.doPrivileged(new PrivilegedAction<>() {
public ProtectionDomain run() { public ProtectionDomain run() {
@ -394,6 +406,7 @@ public abstract class Policy {
* @see Provider * @see Provider
* @since 1.6 * @since 1.6
*/ */
@SuppressWarnings("removal")
public static Policy getInstance(String type, Policy.Parameters params) public static Policy getInstance(String type, Policy.Parameters params)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name"); Objects.requireNonNull(type, "null type name");
@ -455,6 +468,7 @@ public abstract class Policy {
* @see Provider * @see Provider
* @since 1.6 * @since 1.6
*/ */
@SuppressWarnings("removal")
public static Policy getInstance(String type, public static Policy getInstance(String type,
Policy.Parameters params, Policy.Parameters params,
String provider) String provider)
@ -518,6 +532,7 @@ public abstract class Policy {
* @see Provider * @see Provider
* @since 1.6 * @since 1.6
*/ */
@SuppressWarnings("removal")
public static Policy getInstance(String type, public static Policy getInstance(String type,
Policy.Parameters params, Policy.Parameters params,
Provider provider) Provider provider)
@ -769,12 +784,13 @@ public abstract class Policy {
*/ */
private static class PolicyDelegate extends Policy { private static class PolicyDelegate extends Policy {
@SuppressWarnings("removal")
private PolicySpi spi; private PolicySpi spi;
private Provider p; private Provider p;
private String type; private String type;
private Policy.Parameters params; private Policy.Parameters params;
private PolicyDelegate(PolicySpi spi, Provider p, private PolicyDelegate(@SuppressWarnings("removal") PolicySpi spi, Provider p,
String type, Policy.Parameters params) { String type, Policy.Parameters params) {
this.spi = spi; this.spi = spi;
this.p = p; this.p = p;
@ -810,7 +826,13 @@ public abstract class Policy {
* This represents a marker interface for Policy parameters. * This represents a marker interface for Policy parameters.
* *
* @since 1.6 * @since 1.6
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this class is also deprecated and subject to removal.
* There is no replacement for the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public static interface Parameters { } public static interface Parameters { }
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -40,8 +40,14 @@ package java.security;
* *
* *
* @since 1.6 * @since 1.6
* @deprecated This class is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is deprecated
* and subject to removal in a future release. Consequently, this class
* is also deprecated and subject to removal. There is no replacement for
* the Security Manager or this class.
*/ */
@Deprecated(since="17", forRemoval=true)
public abstract class PolicySpi { public abstract class PolicySpi {
/** /**
@ -92,6 +98,7 @@ public abstract class PolicySpi {
* If this operation is not supported, * If this operation is not supported,
* Policy.UNSUPPORTED_EMPTY_COLLECTION is returned. * Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
*/ */
@SuppressWarnings("removal")
protected PermissionCollection engineGetPermissions protected PermissionCollection engineGetPermissions
(CodeSource codesource) { (CodeSource codesource) {
return Policy.UNSUPPORTED_EMPTY_COLLECTION; return Policy.UNSUPPORTED_EMPTY_COLLECTION;
@ -116,6 +123,7 @@ public abstract class PolicySpi {
* If this operation is not supported, * If this operation is not supported,
* Policy.UNSUPPORTED_EMPTY_COLLECTION is returned. * Policy.UNSUPPORTED_EMPTY_COLLECTION is returned.
*/ */
@SuppressWarnings("removal")
protected PermissionCollection engineGetPermissions protected PermissionCollection engineGetPermissions
(ProtectionDomain domain) { (ProtectionDomain domain) {
return Policy.UNSUPPORTED_EMPTY_COLLECTION; return Policy.UNSUPPORTED_EMPTY_COLLECTION;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -73,6 +73,7 @@ public class ProtectionDomain {
private JavaSecurityAccessImpl() { private JavaSecurityAccessImpl() {
} }
@SuppressWarnings("removal")
@Override @Override
public <T> T doIntersectionPrivilege( public <T> T doIntersectionPrivilege(
PrivilegedAction<T> action, PrivilegedAction<T> action,
@ -88,6 +89,7 @@ public class ProtectionDomain {
); );
} }
@SuppressWarnings("removal")
@Override @Override
public <T> T doIntersectionPrivilege( public <T> T doIntersectionPrivilege(
PrivilegedAction<T> action, PrivilegedAction<T> action,
@ -97,10 +99,11 @@ public class ProtectionDomain {
} }
@Override @Override
public ProtectionDomain[] getProtectDomains(AccessControlContext context) { public ProtectionDomain[] getProtectDomains(@SuppressWarnings("removal") AccessControlContext context) {
return context.getContext(); return context.getContext();
} }
@SuppressWarnings("removal")
private static AccessControlContext getCombinedACC( private static AccessControlContext getCombinedACC(
AccessControlContext context, AccessControlContext stack) { AccessControlContext context, AccessControlContext stack) {
AccessControlContext acc = AccessControlContext acc =
@ -309,6 +312,7 @@ public class ProtectionDomain {
* *
* @return true if {@code perm} is implied by this ProtectionDomain. * @return true if {@code perm} is implied by this ProtectionDomain.
*/ */
@SuppressWarnings("removal")
public boolean implies(Permission perm) { public boolean implies(Permission perm) {
if (hasAllPerm) { if (hasAllPerm) {
@ -363,6 +367,7 @@ public class ProtectionDomain {
boolean p2Calculated = false; boolean p2Calculated = false;
if (!staticPermissions) { if (!staticPermissions) {
@SuppressWarnings("removal")
Policy policy = Policy.getPolicyNoCheck(); Policy policy = Policy.getPolicyNoCheck();
if (policy instanceof PolicyFile) { if (policy instanceof PolicyFile) {
// The PolicyFile implementation supports compatibility // The PolicyFile implementation supports compatibility
@ -416,6 +421,7 @@ public class ProtectionDomain {
// Check if policy is set; we don't want to load // Check if policy is set; we don't want to load
// the policy prematurely here // the policy prematurely here
@SuppressWarnings("removal")
PermissionCollection pc = Policy.isSet() && seeAllp() ? PermissionCollection pc = Policy.isSet() && seeAllp() ?
mergePermissions(): mergePermissions():
getPermissions(); getPermissions();
@ -449,6 +455,7 @@ public class ProtectionDomain {
* debug is null, * debug is null,
* caller has Policy.getPolicy permission * caller has Policy.getPolicy permission
*/ */
@SuppressWarnings("removal")
private static boolean seeAllp() { private static boolean seeAllp() {
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
@ -478,6 +485,7 @@ public class ProtectionDomain {
if (staticPermissions) if (staticPermissions)
return permissions; return permissions;
@SuppressWarnings("removal")
PermissionCollection perms = PermissionCollection perms =
java.security.AccessController.doPrivileged java.security.AccessController.doPrivileged
(new java.security.PrivilegedAction<>() { (new java.security.PrivilegedAction<>() {

View File

@ -810,6 +810,7 @@ public abstract class Provider extends Properties {
private void check(String directive) { private void check(String directive) {
checkInitialized(); checkInitialized();
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager(); SecurityManager security = System.getSecurityManager();
if (security != null) { if (security != null) {
security.checkSecurityAccess(directive); security.checkSecurityAccess(directive);

View File

@ -933,6 +933,7 @@ public class SecureRandom extends java.util.Random {
public static SecureRandom getInstanceStrong() public static SecureRandom getInstanceStrong()
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
@SuppressWarnings("removal")
String property = AccessController.doPrivileged( String property = AccessController.doPrivileged(
new PrivilegedAction<>() { new PrivilegedAction<>() {
@Override @Override

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -51,6 +51,7 @@ import sun.security.jca.*;
* @since 1.1 * @since 1.1
*/ */
@SuppressWarnings("removal")
public final class Security { public final class Security {
/* Are we debugging? -- for developers */ /* Are we debugging? -- for developers */

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -32,6 +32,7 @@ package java.security;
* *
* @since 1.6 * @since 1.6
*/ */
@SuppressWarnings("removal")
public class URIParameter implements public class URIParameter implements
Policy.Parameters, javax.security.auth.login.Configuration.Parameters { Policy.Parameters, javax.security.auth.login.Configuration.Parameters {

Some files were not shown because too many files have changed in this diff Show More