diff --git a/make/RunTests.gmk b/make/RunTests.gmk index f1da577de6a..282db4764e7 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -767,7 +767,7 @@ define SetupRunJtregTestBody -vmoption:-XX:MaxRAMPercentage=$$($1_JTREG_MAX_RAM_PERCENTAGE) \ -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 # JIB Artifact resolver diff --git a/src/demo/share/jfc/J2Ddemo/java2d/Tools.java b/src/demo/share/jfc/J2Ddemo/java2d/Tools.java index 62a60098caa..3c01042adf4 100644 --- a/src/demo/share/jfc/J2Ddemo/java2d/Tools.java +++ b/src/demo/share/jfc/J2Ddemo/java2d/Tools.java @@ -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 * modification, are permitted provided that the following conditions @@ -406,7 +406,7 @@ public final class Tools extends JPanel implements ActionListener, if (pDialogState) { printJob.print(aset); } - } catch (java.security.AccessControlException ace) { + } catch (@SuppressWarnings("removal") java.security.AccessControlException ace) { String errmsg = "Applet access control exception; to allow " + "access to printer, set\n" + "permission for \"queuePrintJob\" in " diff --git a/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java b/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java index 34187e10fff..86d3ade19de 100644 --- a/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java +++ b/src/java.base/aix/classes/sun/nio/ch/DefaultSelectorProvider.java @@ -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. * * 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 */ +@SuppressWarnings("removal") public class DefaultSelectorProvider { private static final SelectorProviderImpl INSTANCE; static { diff --git a/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java b/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java index d50aa6bbb6d..dbe8a85b2b2 100644 --- a/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java +++ b/src/java.base/linux/classes/jdk/internal/platform/CgroupUtil.java @@ -39,6 +39,7 @@ import java.util.stream.Stream; public final class CgroupUtil { + @SuppressWarnings("removal") public static Stream readFilePrivileged(Path path) throws IOException { try { PrivilegedExceptionAction> pea = () -> Files.lines(path); @@ -64,7 +65,7 @@ public final class CgroupUtil { static String readStringValue(CgroupSubsystemController controller, String param) throws IOException { PrivilegedExceptionAction pea = () -> Files.newBufferedReader(Paths.get(controller.path(), param)); - try (BufferedReader bufferedReader = + try (@SuppressWarnings("removal") BufferedReader bufferedReader = AccessController.doPrivileged(pea)) { String line = bufferedReader.readLine(); return line; @@ -76,6 +77,7 @@ public final class CgroupUtil { } } + @SuppressWarnings("removal") public static List readAllLinesPrivileged(Path path) throws IOException { try { PrivilegedExceptionAction> pea = () -> Files.readAllLines(path); diff --git a/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java b/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java index 134795c8b28..fa925f54546 100644 --- a/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java +++ b/src/java.base/linux/classes/sun/nio/ch/DefaultSelectorProvider.java @@ -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. * * 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 */ +@SuppressWarnings("removal") public class DefaultSelectorProvider { private static final SelectorProviderImpl INSTANCE; static { diff --git a/src/java.base/macosx/classes/apple/security/AppleProvider.java b/src/java.base/macosx/classes/apple/security/AppleProvider.java index 3b712846d45..8381ffeb891 100644 --- a/src/java.base/macosx/classes/apple/security/AppleProvider.java +++ b/src/java.base/macosx/classes/apple/security/AppleProvider.java @@ -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. * * 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() { /* We are the Apple provider */ super("Apple", PROVIDER_VER, info); diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java index 25126f13c9f..cf97d4e04c0 100644 --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -110,6 +110,7 @@ public final class KeychainStore extends KeyStoreSpi { } private static void permissionCheck() { + @SuppressWarnings("removal") SecurityManager sec = System.getSecurityManager(); if (sec != null) { diff --git a/src/java.base/macosx/classes/java/net/DefaultInterface.java b/src/java.base/macosx/classes/java/net/DefaultInterface.java index 8aaba11227c..1901fcb156a 100644 --- a/src/java.base/macosx/classes/java/net/DefaultInterface.java +++ b/src/java.base/macosx/classes/java/net/DefaultInterface.java @@ -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. * * 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; PrivilegedAction> pa = ni::getInetAddresses; + @SuppressWarnings("removal") Enumeration addrs = AccessController.doPrivileged(pa); while (addrs.hasMoreElements()) { InetAddress addr = addrs.nextElement(); diff --git a/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java b/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java index 131911c1bf3..a010b1706d4 100644 --- a/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java +++ b/src/java.base/macosx/classes/sun/nio/ch/DefaultSelectorProvider.java @@ -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. * * 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 */ +@SuppressWarnings("removal") public class DefaultSelectorProvider { private static final SelectorProviderImpl INSTANCE; static { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java b/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java index 297b78747d9..94f41e614f1 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/DHKeyAgreement.java @@ -66,6 +66,7 @@ extends KeyAgreementSpi { private static final boolean VALUE = getValue(); + @SuppressWarnings("removal") private static boolean getValue() { return AccessController.doPrivileged( (PrivilegedAction) diff --git a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java index c5772b4844c..6038f6de865 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/JceKeyStore.java @@ -683,6 +683,7 @@ public final class JceKeyStore extends KeyStoreSpi { * @exception CertificateException if any of the certificates in the * keystore could not be loaded */ + @SuppressWarnings("removal") public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java b/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java index e50c018fa6c..01330678083 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/SealedObjectForKeyProtector.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -73,6 +73,7 @@ final class SealedObjectForKeyProtector extends SealedObject { return params; } + @SuppressWarnings("removal") final Key getKey(Cipher c, int maxLength) throws IOException, ClassNotFoundException, IllegalBlockSizeException, BadPaddingException { @@ -112,6 +113,7 @@ final class SealedObjectForKeyProtector extends SealedObject { private static final ObjectInputFilter OWN_FILTER; static { + @SuppressWarnings("removal") String prop = AccessController.doPrivileged( (PrivilegedAction) () -> { String tmp = System.getProperty(KEY_SERIAL_FILTER); diff --git a/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java b/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java index 0c7e0ed266a..030c3c078ec 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/SunJCE.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -117,6 +117,7 @@ public final class SunJCE extends Provider { attrs)); } + @SuppressWarnings("removal") public SunJCE() { /* We are the "SunJCE" provider */ super("SunJCE", PROVIDER_VER, info); diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java index aa06bd50ca9..bf2c1f756f3 100644 --- a/src/java.base/share/classes/java/io/File.java +++ b/src/java.base/share/classes/java/io/File.java @@ -770,6 +770,7 @@ public class File * method denies read access to the file */ public boolean canRead() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -798,6 +799,7 @@ public class File * method denies write access to the file */ public boolean canWrite() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -821,6 +823,7 @@ public class File * method denies read access to the file or directory */ public boolean exists() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -851,6 +854,7 @@ public class File * method denies read access to the file */ public boolean isDirectory() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -883,6 +887,7 @@ public class File * method denies read access to the file */ public boolean isFile() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -912,6 +917,7 @@ public class File * @since 1.2 */ public boolean isHidden() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -955,6 +961,7 @@ public class File * method denies read access to the file */ public long lastModified() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -986,6 +993,7 @@ public class File * method denies read access to the file */ public long length() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -1026,6 +1034,7 @@ public class File * @since 1.2 */ public boolean createNewFile() throws IOException { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) security.checkWrite(path); if (isInvalid()) { @@ -1053,6 +1062,7 @@ public class File * delete access to the file */ public boolean delete() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkDelete(path); @@ -1091,6 +1101,7 @@ public class File * @since 1.2 */ public void deleteOnExit() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkDelete(path); @@ -1154,6 +1165,7 @@ public class File * the directory */ private final String[] normalizedList() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(path); @@ -1356,6 +1368,7 @@ public class File * method does not permit the named directory to be created */ public boolean mkdir() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1438,6 +1451,7 @@ public class File if (dest == null) { throw new NullPointerException(); } + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1477,6 +1491,7 @@ public class File */ public boolean setLastModified(long time) { if (time < 0) throw new IllegalArgumentException("Negative time"); + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1507,6 +1522,7 @@ public class File * @since 1.2 */ public boolean setReadOnly() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1550,6 +1566,7 @@ public class File * @since 1.6 */ public boolean setWritable(boolean writable, boolean ownerOnly) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1628,6 +1645,7 @@ public class File * @since 1.6 */ public boolean setReadable(boolean readable, boolean ownerOnly) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1709,6 +1727,7 @@ public class File * @since 1.6 */ public boolean setExecutable(boolean executable, boolean ownerOnly) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(path); @@ -1772,6 +1791,7 @@ public class File * @since 1.6 */ public boolean canExecute() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkExec(path); @@ -1854,6 +1874,7 @@ public class File * @see FileStore#getTotalSpace */ public long getTotalSpace() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); @@ -1897,6 +1918,7 @@ public class File * @see FileStore#getUnallocatedSpace */ public long getFreeSpace() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); @@ -1943,6 +1965,7 @@ public class File * @see FileStore#getUsableSpace */ public long getUsableSpace() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); @@ -1977,6 +2000,7 @@ public class File } return subNameLength; } + @SuppressWarnings("removal") static File generateFile(String prefix, String suffix, File dir) throws IOException { @@ -2125,6 +2149,7 @@ public class File File tmpdir = (directory != null) ? directory : TempDirectory.location(); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); File f; do { diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index 4b6831c81c6..1d078142512 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -140,6 +140,7 @@ public class FileInputStream extends InputStream */ public FileInputStream(File file) throws FileNotFoundException { String name = (file != null ? file.getPath() : null); + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(name); @@ -182,6 +183,7 @@ public class FileInputStream extends InputStream * @see SecurityManager#checkRead(java.io.FileDescriptor) */ public FileInputStream(FileDescriptor fdObj) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (fdObj == null) { throw new NullPointerException(); diff --git a/src/java.base/share/classes/java/io/FileOutputStream.java b/src/java.base/share/classes/java/io/FileOutputStream.java index 950c3d8529e..2e71b2bf700 100644 --- a/src/java.base/share/classes/java/io/FileOutputStream.java +++ b/src/java.base/share/classes/java/io/FileOutputStream.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -217,6 +217,7 @@ public class FileOutputStream extends OutputStream throws FileNotFoundException { String name = (file != null ? file.getPath() : null); + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkWrite(name); @@ -259,6 +260,7 @@ public class FileOutputStream extends OutputStream * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor) */ public FileOutputStream(FileDescriptor fdObj) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (fdObj == null) { throw new NullPointerException(); diff --git a/src/java.base/share/classes/java/io/FilePermission.java b/src/java.base/share/classes/java/io/FilePermission.java index 40d057f9495..83a1e98dc55 100644 --- a/src/java.base/share/classes/java/io/FilePermission.java +++ b/src/java.base/share/classes/java/io/FilePermission.java @@ -308,6 +308,7 @@ public final class FilePermission extends Permission implements Serializable { * @param mask the actions mask to use. * */ + @SuppressWarnings("removal") private void init(int mask) { if ((mask & ALL) != mask) throw new IllegalArgumentException("invalid actions mask"); diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java index bbc9042ebca..f55c04d28f3 100644 --- a/src/java.base/share/classes/java/io/ObjectInputFilter.java +++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -219,6 +219,7 @@ public interface ObjectInputFilter { * * @since 9 */ + @SuppressWarnings("removal") final class Config { /* No instances. */ private Config() {} diff --git a/src/java.base/share/classes/java/io/ObjectInputStream.java b/src/java.base/share/classes/java/io/ObjectInputStream.java index af7c6fbe74e..203df9c52ad 100644 --- a/src/java.base/share/classes/java/io/ObjectInputStream.java +++ b/src/java.base/share/classes/java/io/ObjectInputStream.java @@ -404,6 +404,7 @@ public class ObjectInputStream * @see java.io.SerializablePermission */ protected ObjectInputStream() throws IOException, SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); @@ -915,6 +916,7 @@ public class ObjectInputStream return enable; } if (enable) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SUBSTITUTION_PERMISSION); @@ -1307,6 +1309,7 @@ public class ObjectInputStream * @since 9 */ public final void setObjectInputFilter(ObjectInputFilter filter) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION); @@ -1575,6 +1578,7 @@ public class ObjectInputStream if (cl == ObjectInputStream.class) { return; } + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm == null) { return; @@ -1596,6 +1600,7 @@ public class ObjectInputStream * override security-sensitive non-final methods. Returns TRUE if subclass * is "safe", FALSE otherwise. */ + @SuppressWarnings("removal") private static Boolean auditSubclass(Class subcl) { return AccessController.doPrivileged( new PrivilegedAction() { @@ -2660,10 +2665,11 @@ public class ObjectInputStream final ObjectInputValidation obj; final int priority; Callback next; + @SuppressWarnings("removal") final AccessControlContext acc; Callback(ObjectInputValidation obj, int priority, Callback next, - AccessControlContext acc) + @SuppressWarnings("removal") AccessControlContext acc) { this.obj = obj; this.priority = priority; @@ -2697,6 +2703,7 @@ public class ObjectInputStream prev = cur; cur = cur.next; } + @SuppressWarnings("removal") AccessControlContext acc = AccessController.getContext(); if (prev != null) { prev.next = new Callback(obj, priority, cur, acc); @@ -2712,6 +2719,7 @@ public class ObjectInputStream * throws an InvalidObjectException, the callback process is terminated * and the exception propagated upwards. */ + @SuppressWarnings("removal") void doCallbacks() throws InvalidObjectException { try { while (list != null) { diff --git a/src/java.base/share/classes/java/io/ObjectOutputStream.java b/src/java.base/share/classes/java/io/ObjectOutputStream.java index b10e380ca57..d647c0c0e65 100644 --- a/src/java.base/share/classes/java/io/ObjectOutputStream.java +++ b/src/java.base/share/classes/java/io/ObjectOutputStream.java @@ -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. * * 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, * as true or false for extended information about exception's place */ + @SuppressWarnings("removal") private static final boolean extendedDebugInfo = java.security.AccessController.doPrivileged( new sun.security.action.GetBooleanAction( @@ -274,6 +275,7 @@ public class ObjectOutputStream * @see java.io.SerializablePermission */ protected ObjectOutputStream() throws IOException, SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SUBCLASS_IMPLEMENTATION_PERMISSION); @@ -621,6 +623,7 @@ public class ObjectOutputStream return enable; } if (enable) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SUBSTITUTION_PERMISSION); @@ -1052,6 +1055,7 @@ public class ObjectOutputStream if (cl == ObjectOutputStream.class) { return; } + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm == null) { return; @@ -1073,6 +1077,7 @@ public class ObjectOutputStream * override security-sensitive non-final methods. Returns TRUE if subclass * is "safe", FALSE otherwise. */ + @SuppressWarnings("removal") private static Boolean auditSubclass(Class subcl) { return AccessController.doPrivileged( new PrivilegedAction<>() { diff --git a/src/java.base/share/classes/java/io/ObjectStreamClass.java b/src/java.base/share/classes/java/io/ObjectStreamClass.java index 733281c896a..1eff6c27278 100644 --- a/src/java.base/share/classes/java/io/ObjectStreamClass.java +++ b/src/java.base/share/classes/java/io/ObjectStreamClass.java @@ -101,6 +101,7 @@ public class ObjectStreamClass implements Serializable { NO_FIELDS; /** reflection factory for obtaining serialization constructors */ + @SuppressWarnings("removal") private static final ReflectionFactory reflFactory = AccessController.doPrivileged( new ReflectionFactory.GetReflectionFactoryAction()); @@ -278,6 +279,7 @@ public class ObjectStreamClass implements Serializable { * * @return the SUID of the class described by this descriptor */ + @SuppressWarnings("removal") public long getSerialVersionUID() { // REMIND: synchronize instead of relying on volatile? if (suid == null) { @@ -301,6 +303,7 @@ public class ObjectStreamClass implements Serializable { * * @return the {@code Class} instance that this descriptor represents */ + @SuppressWarnings("removal") @CallerSensitive public Class forClass() { if (cl == null) { @@ -460,6 +463,7 @@ public class ObjectStreamClass implements Serializable { * Returns the value contained by this EntryFuture, blocking if * necessary until a value is set. */ + @SuppressWarnings("removal") synchronized Object get() { boolean interrupted = false; while (entry == unset) { @@ -493,6 +497,7 @@ public class ObjectStreamClass implements Serializable { /** * Creates local class descriptor representing given class. */ + @SuppressWarnings("removal") private ObjectStreamClass(final Class cl) { this.cl = cl; name = cl.getName(); @@ -620,6 +625,7 @@ public class ObjectStreamClass implements Serializable { * ProtectionDomain that separate the concrete class {@code cl} * from its ancestor's declaring {@code cons}, or {@code null}. */ + @SuppressWarnings("removal") private ProtectionDomain[] getProtectionDomains(Constructor cons, Class cl) { ProtectionDomain[] domains = null; @@ -1130,6 +1136,7 @@ public class ObjectStreamClass implements Serializable { * class is non-serializable or if the appropriate no-arg constructor is * inaccessible/unavailable. */ + @SuppressWarnings("removal") Object newInstance() throws InstantiationException, InvocationTargetException, UnsupportedOperationException @@ -1572,6 +1579,7 @@ public class ObjectStreamClass implements Serializable { * the not found ( which should never happen for correctly generated record * classes ). */ + @SuppressWarnings("removal") private static MethodHandle canonicalRecordCtr(Class cls) { assert cls.isRecord() : "Expected record, got: " + cls; PrivilegedAction pa = () -> { @@ -2584,6 +2592,7 @@ public class ObjectStreamClass implements Serializable { * and return * {@code Object} */ + @SuppressWarnings("removal") static MethodHandle deserializationCtr(ObjectStreamClass desc) { // check the cached value 1st MethodHandle mh = desc.deserializationCtr; diff --git a/src/java.base/share/classes/java/io/ObjectStreamField.java b/src/java.base/share/classes/java/io/ObjectStreamField.java index f8ecb71bd9b..9df32cf2fb0 100644 --- a/src/java.base/share/classes/java/io/ObjectStreamField.java +++ b/src/java.base/share/classes/java/io/ObjectStreamField.java @@ -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. * * 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 * serializable field */ + @SuppressWarnings("removal") @CallerSensitive public Class getType() { if (System.getSecurityManager() != null) { diff --git a/src/java.base/share/classes/java/io/RandomAccessFile.java b/src/java.base/share/classes/java/io/RandomAccessFile.java index 5f6bcfaa6ac..5443018ca8b 100644 --- a/src/java.base/share/classes/java/io/RandomAccessFile.java +++ b/src/java.base/share/classes/java/io/RandomAccessFile.java @@ -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. * * 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 " + "\"r\", \"rw\", \"rws\"," + " or \"rwd\""); + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkRead(name); diff --git a/src/java.base/share/classes/java/lang/CharacterName.java b/src/java.base/share/classes/java/lang/CharacterName.java index 7dd83feecd1..4807635802b 100644 --- a/src/java.base/share/classes/java/lang/CharacterName.java +++ b/src/java.base/share/classes/java/lang/CharacterName.java @@ -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. * * 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 CharacterName() { - try (DataInputStream dis = new DataInputStream(new InflaterInputStream( + try (@SuppressWarnings("removal") DataInputStream dis = new DataInputStream(new InflaterInputStream( AccessController.doPrivileged(new PrivilegedAction<>() { public InputStream run() { return getClass().getResourceAsStream("uniName.dat"); diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index e30db2c4d86..b8bf7de250e 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -450,6 +450,7 @@ public final class Class implements java.io.Serializable, throws ClassNotFoundException { Class caller = null; + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { // Reflective call to get caller class is only needed if a security manager @@ -519,6 +520,7 @@ public final class Class implements java.io.Serializable, * @jls 12.3 Linking of Classes and Interfaces * @since 9 */ + @SuppressWarnings("removal") @CallerSensitive public static Class forName(Module module, String name) { Objects.requireNonNull(module); @@ -599,6 +601,7 @@ public final class Class implements java.io.Serializable, * s.checkPackageAccess()} denies access to the package * of this class. */ + @SuppressWarnings("removal") @CallerSensitive @Deprecated(since="9") public T newInstance() @@ -892,6 +895,7 @@ public final class Class implements java.io.Serializable, ClassLoader cl = getClassLoader0(); if (cl == null) return null; + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { ClassLoader.checkClassLoaderPermission(cl, Reflection.getCallerClass()); @@ -1357,6 +1361,7 @@ public final class Class implements java.io.Serializable, // Perform access check final Class enclosingCandidate = enclosingInfo.getEnclosingClass(); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, @@ -1513,6 +1518,7 @@ public final class Class implements java.io.Serializable, // Perform access check final Class enclosingCandidate = enclosingInfo.getEnclosingClass(); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { enclosingCandidate.checkMemberAccess(sm, Member.DECLARED, @@ -1560,6 +1566,7 @@ public final class Class implements java.io.Serializable, final Class candidate = getDeclaringClass0(); if (candidate != null) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { candidate.checkPackageAccess(sm, @@ -1614,6 +1621,7 @@ public final class Class implements java.io.Serializable, } if (enclosingCandidate != null) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { enclosingCandidate.checkPackageAccess(sm, @@ -1840,6 +1848,7 @@ public final class Class implements java.io.Serializable, * * @since 1.1 */ + @SuppressWarnings("removal") @CallerSensitive public Class[] getClasses() { SecurityManager sm = System.getSecurityManager(); @@ -1911,6 +1920,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Field[] getFields() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2001,6 +2011,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Method[] getMethods() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2041,6 +2052,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor[] getConstructors() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2095,6 +2107,7 @@ public final class Class implements java.io.Serializable, public Field getField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2204,6 +2217,7 @@ public final class Class implements java.io.Serializable, public Method getMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException { Objects.requireNonNull(name); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2248,6 +2262,7 @@ public final class Class implements java.io.Serializable, public Constructor getConstructor(Class... parameterTypes) throws NoSuchMethodException, SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true); @@ -2295,6 +2310,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Class[] getDeclaredClasses() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), false); @@ -2347,6 +2363,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Field[] getDeclaredFields() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2408,6 +2425,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public RecordComponent[] getRecordComponents() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2478,6 +2496,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Method[] getDeclaredMethods() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2528,6 +2547,7 @@ public final class Class implements java.io.Serializable, */ @CallerSensitive public Constructor[] getDeclaredConstructors() throws SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2580,6 +2600,7 @@ public final class Class implements java.io.Serializable, public Field getDeclaredField(String name) throws NoSuchFieldException, SecurityException { Objects.requireNonNull(name); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2644,6 +2665,7 @@ public final class Class implements java.io.Serializable, public Method getDeclaredMethod(String name, Class... parameterTypes) throws NoSuchMethodException, SecurityException { Objects.requireNonNull(name); + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2722,6 +2744,7 @@ public final class Class implements java.io.Serializable, public Constructor getDeclaredConstructor(Class... parameterTypes) throws NoSuchMethodException, SecurityException { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkMemberAccess(sm, Member.DECLARED, Reflection.getCallerClass(), true); @@ -2968,6 +2991,7 @@ public final class Class implements java.io.Serializable, * @since 1.2 */ public java.security.ProtectionDomain getProtectionDomain() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SecurityConstants.GET_PD_PERMISSION); @@ -3013,7 +3037,7 @@ public final class Class implements java.io.Serializable, * *

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) { /* 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. @@ -3037,7 +3061,7 @@ public final class Class implements java.io.Serializable, * * 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) { final ClassLoader cl = getClassLoader0(); @@ -3066,7 +3090,7 @@ public final class Class implements java.io.Serializable, * all classes provided must be loaded by the same ClassLoader * 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 cl = subClasses[0].getClassLoader0(); @@ -3762,6 +3786,7 @@ public final class Class implements java.io.Serializable, } // Fetches the factory for reflective objects + @SuppressWarnings("removal") private static ReflectionFactory getReflectionFactory() { if (reflectionFactory == null) { reflectionFactory = @@ -3794,6 +3819,7 @@ public final class Class implements java.io.Serializable, * identical to getEnumConstants except that the result is * uncloned, cached, and shared by all callers. */ + @SuppressWarnings("removal") T[] getEnumConstantsShared() { T[] constants = enumConstants; if (constants == null) { @@ -4204,6 +4230,7 @@ public final class Class implements java.io.Serializable, return this; } // returning a different class requires a security check + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkPackageAccess(sm, @@ -4296,6 +4323,7 @@ public final class Class implements java.io.Serializable, if (members.length > 1) { // If we return anything other than the current class we need // a security check + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkPackageAccess(sm, @@ -4492,6 +4520,7 @@ public final class Class implements java.io.Serializable, } if (subClasses.length > 0) { // If we return some classes we need a security check: + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { checkPackageAccessForPermittedSubclasses(sm, diff --git a/src/java.base/share/classes/java/lang/ClassLoader.java b/src/java.base/share/classes/java/lang/ClassLoader.java index 7a17a678389..9c249df4ff8 100644 --- a/src/java.base/share/classes/java/lang/ClassLoader.java +++ b/src/java.base/share/classes/java/lang/ClassLoader.java @@ -365,6 +365,7 @@ public abstract class ClassLoader { throw new IllegalArgumentException("name must be non-empty or null"); } + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkCreateClassLoader(); @@ -671,6 +672,7 @@ public abstract class ClassLoader { } // Invoked by the VM after loading class with this loader. + @SuppressWarnings("removal") private void checkPackageAccess(Class cls, ProtectionDomain pd) { final SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -1791,6 +1793,7 @@ public abstract class ClassLoader { public final ClassLoader getParent() { if (parent == null) return null; + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { // Check access to the parent class loader @@ -1834,6 +1837,7 @@ public abstract class ClassLoader { */ @CallerSensitive public static ClassLoader getPlatformClassLoader() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); ClassLoader loader = getBuiltinPlatformClassLoader(); if (sm != null) { @@ -1933,6 +1937,7 @@ public abstract class ClassLoader { default: // system fully initialized assert VM.isBooted() && scl != null; + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { 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. */ static void checkClassLoaderPermission(ClassLoader cl, Class caller) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { // caller can be null if the VM is requesting it diff --git a/src/java.base/share/classes/java/lang/LiveStackFrame.java b/src/java.base/share/classes/java/lang/LiveStackFrame.java index aada8c8639c..7507bbc8877 100644 --- a/src/java.base/share/classes/java/lang/LiveStackFrame.java +++ b/src/java.base/share/classes/java/lang/LiveStackFrame.java @@ -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. * * 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")}. */ public static StackWalker getStackWalker(Set options) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("liveStackFrames")); diff --git a/src/java.base/share/classes/java/lang/Module.java b/src/java.base/share/classes/java/lang/Module.java index 62b5e671843..ab7d2103850 100644 --- a/src/java.base/share/classes/java/lang/Module.java +++ b/src/java.base/share/classes/java/lang/Module.java @@ -204,6 +204,7 @@ public final class Module implements AnnotatedElement { * If denied by the security manager */ public ClassLoader getClassLoader() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); @@ -1471,6 +1472,7 @@ public final class Module implements AnnotatedElement { // cached class file with annotations private volatile Class moduleInfoClass; + @SuppressWarnings("removal") private Class moduleInfoClass() { Class clazz = this.moduleInfoClass; if (clazz != null) diff --git a/src/java.base/share/classes/java/lang/ModuleLayer.java b/src/java.base/share/classes/java/lang/ModuleLayer.java index 86fde6c7f13..6cecfe6d388 100644 --- a/src/java.base/share/classes/java/lang/ModuleLayer.java +++ b/src/java.base/share/classes/java/lang/ModuleLayer.java @@ -699,12 +699,14 @@ public final class ModuleLayer { } private static void checkCreateClassLoaderPermission() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION); } private static void checkGetClassLoaderPermission() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) sm.checkPermission(SecurityConstants.GET_CLASSLOADER_PERMISSION); diff --git a/src/java.base/share/classes/java/lang/Package.java b/src/java.base/share/classes/java/lang/Package.java index 500f22cebf2..22a32c36894 100644 --- a/src/java.base/share/classes/java/lang/Package.java +++ b/src/java.base/share/classes/java/lang/Package.java @@ -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. * * 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"; Module module = module(); PrivilegedAction pa = module::getClassLoader; + @SuppressWarnings("removal") ClassLoader loader = AccessController.doPrivileged(pa); Class c; if (loader != null) { diff --git a/src/java.base/share/classes/java/lang/ProcessBuilder.java b/src/java.base/share/classes/java/lang/ProcessBuilder.java index c909ca6789f..d096bdad7b0 100644 --- a/src/java.base/share/classes/java/lang/ProcessBuilder.java +++ b/src/java.base/share/classes/java/lang/ProcessBuilder.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -348,6 +348,7 @@ public final class ProcessBuilder * @see System#getenv() */ public Map environment() { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) security.checkPermission(new RuntimePermission("getenv.*")); @@ -1092,6 +1093,7 @@ public final class ProcessBuilder // Throws IndexOutOfBoundsException if command is empty String prog = cmdarray[0]; + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) security.checkExec(prog); diff --git a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java index 883a15ebb02..81397e24959 100644 --- a/src/java.base/share/classes/java/lang/ProcessHandleImpl.java +++ b/src/java.base/share/classes/java/lang/ProcessHandleImpl.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.lang; import java.lang.annotation.Native; +import java.security.AccessController; import java.security.PrivilegedAction; import java.time.Duration; import java.time.Instant; @@ -40,8 +41,6 @@ import java.util.concurrent.ThreadLocalRandom; import java.util.stream.IntStream; import java.util.stream.Stream; -import static java.security.AccessController.doPrivileged; - /** * ProcessHandleImpl is the implementation of ProcessHandle. * @@ -83,8 +82,9 @@ final class ProcessHandleImpl implements ProcessHandle { /** * The thread pool of "process reaper" daemon threads. */ + @SuppressWarnings("removal") private static final Executor processReaperExecutor = - doPrivileged((PrivilegedAction) () -> { + AccessController.doPrivileged((PrivilegedAction) () -> { // Initialize ThreadLocalRandom now to avoid using the smaller stack // of the processReaper threads. ThreadLocalRandom.current(); @@ -238,6 +238,7 @@ final class ProcessHandleImpl implements ProcessHandle { * @throws SecurityException if RuntimePermission("manageProcess") is not granted */ static Optional get(long pid) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); @@ -278,6 +279,7 @@ final class ProcessHandleImpl implements ProcessHandle { * @throws SecurityException if RuntimePermission("manageProcess") is not granted */ public static ProcessHandleImpl current() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); @@ -301,6 +303,7 @@ final class ProcessHandleImpl implements ProcessHandle { * security policy */ public Optional parent() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); @@ -419,6 +422,7 @@ final class ProcessHandleImpl implements ProcessHandle { * @return a stream of ProcessHandles */ static Stream children(long pid) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); @@ -439,6 +443,7 @@ final class ProcessHandleImpl implements ProcessHandle { @Override public Stream descendants() { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("manageProcess")); diff --git a/src/java.base/share/classes/java/lang/PublicMethods.java b/src/java.base/share/classes/java/lang/PublicMethods.java index 31e87873387..b9851e2f049 100644 --- a/src/java.base/share/classes/java/lang/PublicMethods.java +++ b/src/java.base/share/classes/java/lang/PublicMethods.java @@ -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. * * 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. */ private static final class Key { + @SuppressWarnings("removal") private static final ReflectionFactory reflectionFactory = AccessController.doPrivileged( new ReflectionFactory.GetReflectionFactoryAction()); diff --git a/src/java.base/share/classes/java/lang/Runtime.java b/src/java.base/share/classes/java/lang/Runtime.java index 5348bf4d7d4..ba6e82af703 100644 --- a/src/java.base/share/classes/java/lang/Runtime.java +++ b/src/java.base/share/classes/java/lang/Runtime.java @@ -107,6 +107,7 @@ public class Runtime { * @see #halt(int) */ public void exit(int status) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkExit(status); @@ -207,6 +208,7 @@ public class Runtime { * @since 1.3 */ public void addShutdownHook(Thread hook) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("shutdownHooks")); @@ -235,6 +237,7 @@ public class Runtime { * @since 1.3 */ public boolean removeShutdownHook(Thread hook) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("shutdownHooks")); @@ -270,6 +273,7 @@ public class Runtime { * @since 1.3 */ public void halt(int status) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkExit(status); @@ -734,6 +738,7 @@ public class Runtime { } void load0(Class fromClass, String filename) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(filename); @@ -797,6 +802,7 @@ public class Runtime { } void loadLibrary0(Class fromClass, String libname) { + @SuppressWarnings("removal") SecurityManager security = System.getSecurityManager(); if (security != null) { security.checkLink(libname); diff --git a/src/java.base/share/classes/java/lang/SecurityManager.java b/src/java.base/share/classes/java/lang/SecurityManager.java index 45b1431ece2..2facf5ff9e6 100644 --- a/src/java.base/share/classes/java/lang/SecurityManager.java +++ b/src/java.base/share/classes/java/lang/SecurityManager.java @@ -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. * * This code is free software; you can redistribute it and/or modify it @@ -79,9 +79,9 @@ import sun.security.util.SecurityConstants; * permitted. *

* Environments using a security manager will typically set the security - * manager at startup. In the JDK implementation, this is done by setting - * the system property {@code java.security.manager} on the command line to - * the class name of the security manager. It can also be set to the empty + * manager at startup. In the JDK implementation, this is done by setting the + * system property {@systemProperty java.security.manager} on the command line + * 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 * default {@code java.lang.SecurityManager}. If a class name is specified, * 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 * * @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 JEP 411 for + * discussion and alternatives. */ +@Deprecated(since="17", forRemoval=true) public class SecurityManager { /* @@ -340,6 +345,7 @@ public class SecurityManager { */ public SecurityManager() { synchronized(SecurityManager.class) { + @SuppressWarnings("removal") SecurityManager sm = System.getSecurityManager(); if (sm != null) { // ask the currently installed security manager if we @@ -385,6 +391,7 @@ public class SecurityManager { * java.lang.Object) checkRead * @see java.security.AccessControlContext AccessControlContext */ + @SuppressWarnings("removal") public Object getSecurityContext() { return AccessController.getContext(); } @@ -404,6 +411,7 @@ public class SecurityManager { * {@code null}. * @since 1.2 */ + @SuppressWarnings("removal") public void checkPermission(Permission perm) { java.security.AccessController.checkPermission(perm); } @@ -439,6 +447,7 @@ public class SecurityManager { * @see java.security.AccessControlContext#checkPermission(java.security.Permission) * @since 1.2 */ + @SuppressWarnings("removal") public void checkPermission(Permission perm, Object context) { if (context instanceof AccessControlContext) { ((AccessControlContext)context).checkPermission(perm); @@ -1081,10 +1090,9 @@ public class SecurityManager { * @throws NullPointerException if the address argument is * {@code null}. * @since 1.1 - * @deprecated Use #checkPermission(java.security.Permission) instead * @see #checkPermission(java.security.Permission) checkPermission */ - @Deprecated(since="1.4") + @Deprecated(since="1.4", forRemoval=true) public void checkMulticast(InetAddress maddr, byte ttl) { String host = maddr.getHostAddress(); if (!host.startsWith("[") && host.indexOf(':') != -1) { @@ -1332,6 +1340,7 @@ public class SecurityManager { * Do we need to update our property array? */ if (!packageAccessValid) { + @SuppressWarnings("removal") String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<>() { @@ -1431,6 +1440,7 @@ public class SecurityManager { * Do we need to update our property array? */ if (!packageDefinitionValid) { + @SuppressWarnings("removal") String tmpPropertyStr = AccessController.doPrivileged( new PrivilegedAction<>() { diff --git a/src/java.base/share/classes/java/lang/StackWalker.java b/src/java.base/share/classes/java/lang/StackWalker.java index d1d28b83cc5..9f8a24f1e9e 100644 --- a/src/java.base/share/classes/java/lang/StackWalker.java +++ b/src/java.base/share/classes/java/lang/StackWalker.java @@ -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. * * 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