Skip to content

Commit

Permalink
add supresswarnings annotations automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
wangweij committed May 17, 2021
1 parent 26a54a8 commit eb6c566
Show file tree
Hide file tree
Showing 815 changed files with 1,796 additions and 93 deletions.
2 changes: 1 addition & 1 deletion src/demo/share/jfc/J2Ddemo/java2d/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ public void run() {
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 "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

public final class CgroupUtil {

@SuppressWarnings("removal")
public static Stream<String> readFilePrivileged(Path path) throws IOException {
try {
PrivilegedExceptionAction<Stream<String>> pea = () -> Files.lines(path);
Expand All @@ -64,7 +65,7 @@ static void unwrapIOExceptionAndRethrow(PrivilegedActionException pae) throws IO
static String readStringValue(CgroupSubsystemController controller, String param) throws IOException {
PrivilegedExceptionAction<BufferedReader> 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;
Expand All @@ -76,6 +77,7 @@ static String readStringValue(CgroupSubsystemController controller, String param
}
}

@SuppressWarnings("removal")
public static List<String> readAllLinesPrivileged(Path path) throws IOException {
try {
PrivilegedExceptionAction<List<String>> pea = () -> Files.readAllLines(path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public Object newInstance(Object ctrParamObj)
}


@SuppressWarnings("removal")
public AppleProvider() {
/* We are the Apple provider */
super("Apple", PROVIDER_VER, info);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ class TrustedCertEntry {
}

private static void permissionCheck() {
@SuppressWarnings("removal")
SecurityManager sec = System.getSecurityManager();

if (sec != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ private static NetworkInterface chooseDefaultInterface() {

boolean ip4 = false, ip6 = false, isNonLinkLocal = false;
PrivilegedAction<Enumeration<InetAddress>> pa = ni::getInetAddresses;
@SuppressWarnings("removal")
Enumeration<InetAddress> addrs = AccessController.doPrivileged(pa);
while (addrs.hasMoreElements()) {
InetAddress addr = addrs.nextElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* Creates this platform's default SelectorProvider
*/

@SuppressWarnings("removal")
public class DefaultSelectorProvider {
private static final SelectorProviderImpl INSTANCE;
static {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private static class AllowKDF {

private static final boolean VALUE = getValue();

@SuppressWarnings("removal")
private static boolean getValue() {
return AccessController.doPrivileged(
(PrivilegedAction<Boolean>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ public void engineStore(OutputStream stream, char[] password)
* @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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ AlgorithmParameters getParameters() {
return params;
}

@SuppressWarnings("removal")
final Key getKey(Cipher c, int maxLength)
throws IOException, ClassNotFoundException, IllegalBlockSizeException,
BadPaddingException {
Expand Down Expand Up @@ -112,6 +113,7 @@ private static class DeserializationChecker implements ObjectInputFilter {
private static final ObjectInputFilter OWN_FILTER;

static {
@SuppressWarnings("removal")
String prop = AccessController.doPrivileged(
(PrivilegedAction<String>) () -> {
String tmp = System.getProperty(KEY_SERIAL_FILTER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ private void psA(String type, String algo, String cn,
attrs));
}

@SuppressWarnings("removal")
public SunJCE() {
/* We are the "SunJCE" provider */
super("SunJCE", PROVIDER_VER, info);
Expand Down
25 changes: 25 additions & 0 deletions src/java.base/share/classes/java/io/File.java
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,7 @@ public URI toURI() {
* method denies read access to the file
*/
public boolean canRead() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -798,6 +799,7 @@ public boolean canRead() {
* method denies write access to the file
*/
public boolean canWrite() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand All @@ -821,6 +823,7 @@ public boolean canWrite() {
* method denies read access to the file or directory
*/
public boolean exists() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -851,6 +854,7 @@ public boolean exists() {
* method denies read access to the file
*/
public boolean isDirectory() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -883,6 +887,7 @@ public boolean isDirectory() {
* method denies read access to the file
*/
public boolean isFile() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -912,6 +917,7 @@ public boolean isFile() {
* @since 1.2
*/
public boolean isHidden() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -955,6 +961,7 @@ public boolean isHidden() {
* method denies read access to the file
*/
public long lastModified() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -986,6 +993,7 @@ public long lastModified() {
* method denies read access to the file
*/
public long length() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -1026,6 +1034,7 @@ public long length() {
* @since 1.2
*/
public boolean createNewFile() throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) security.checkWrite(path);
if (isInvalid()) {
Expand Down Expand Up @@ -1053,6 +1062,7 @@ public boolean createNewFile() throws IOException {
* delete access to the file
*/
public boolean delete() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkDelete(path);
Expand Down Expand Up @@ -1091,6 +1101,7 @@ public boolean delete() {
* @since 1.2
*/
public void deleteOnExit() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkDelete(path);
Expand Down Expand Up @@ -1154,6 +1165,7 @@ public String[] list() {
* the directory
*/
private final String[] normalizedList() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(path);
Expand Down Expand Up @@ -1356,6 +1368,7 @@ public File[] listFiles(FileFilter filter) {
* 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);
Expand Down Expand Up @@ -1438,6 +1451,7 @@ public boolean renameTo(File dest) {
if (dest == null) {
throw new NullPointerException();
}
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand Down Expand Up @@ -1477,6 +1491,7 @@ public boolean renameTo(File dest) {
*/
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);
Expand Down Expand Up @@ -1507,6 +1522,7 @@ public boolean setLastModified(long time) {
* @since 1.2
*/
public boolean setReadOnly() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand Down Expand Up @@ -1550,6 +1566,7 @@ public boolean setReadOnly() {
* @since 1.6
*/
public boolean setWritable(boolean writable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand Down Expand Up @@ -1628,6 +1645,7 @@ public boolean setWritable(boolean writable) {
* @since 1.6
*/
public boolean setReadable(boolean readable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand Down Expand Up @@ -1709,6 +1727,7 @@ public boolean setReadable(boolean readable) {
* @since 1.6
*/
public boolean setExecutable(boolean executable, boolean ownerOnly) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(path);
Expand Down Expand Up @@ -1772,6 +1791,7 @@ public boolean setExecutable(boolean executable) {
* @since 1.6
*/
public boolean canExecute() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkExec(path);
Expand Down Expand Up @@ -1854,6 +1874,7 @@ public static File[] listRoots() {
* @see FileStore#getTotalSpace
*/
public long getTotalSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
Expand Down Expand Up @@ -1897,6 +1918,7 @@ public long getTotalSpace() {
* @see FileStore#getUnallocatedSpace
*/
public long getFreeSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
Expand Down Expand Up @@ -1943,6 +1965,7 @@ public long getFreeSpace() {
* @see FileStore#getUsableSpace
*/
public long getUsableSpace() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new RuntimePermission("getFileSystemAttributes"));
Expand Down Expand Up @@ -1977,6 +2000,7 @@ private static int shortenSubName(int subNameLength, int excess,
}
return subNameLength;
}
@SuppressWarnings("removal")
static File generateFile(String prefix, String suffix, File dir)
throws IOException
{
Expand Down Expand Up @@ -2125,6 +2149,7 @@ public static File createTempFile(String prefix, String suffix,

File tmpdir = (directory != null) ? directory
: TempDirectory.location();
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
File f;
do {
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/io/FileInputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public FileInputStream(String name) throws FileNotFoundException {
*/
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);
Expand Down Expand Up @@ -179,6 +180,7 @@ public FileInputStream(File file) throws FileNotFoundException {
* @see SecurityManager#checkRead(java.io.FileDescriptor)
*/
public FileInputStream(FileDescriptor fdObj) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (fdObj == null) {
throw new NullPointerException();
Expand Down
2 changes: 2 additions & 0 deletions src/java.base/share/classes/java/io/FileOutputStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ public FileOutputStream(File file, boolean append)
throws FileNotFoundException
{
String name = (file != null ? file.getPath() : null);
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(name);
Expand Down Expand Up @@ -259,6 +260,7 @@ public FileOutputStream(File file, boolean append)
* @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
*/
public FileOutputStream(FileDescriptor fdObj) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (fdObj == null) {
throw new NullPointerException();
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/io/FilePermission.java
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ public FilePermission newPermUsingAltPath(FilePermission input) {
* @param mask the actions mask to use.
*
*/
@SuppressWarnings("removal")
private void init(int mask) {
if ((mask & ALL) != mask)
throw new IllegalArgumentException("invalid actions mask");
Expand Down
1 change: 1 addition & 0 deletions src/java.base/share/classes/java/io/ObjectInputFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ enum Status {
*
* @since 9
*/
@SuppressWarnings("removal")
final class Config {
/* No instances. */
private Config() {}
Expand Down
Loading

0 comments on commit eb6c566

Please sign in to comment.