8353641: Deprecate core library permission classes for removal

Reviewed-by: mullan, iris
This commit is contained in:
Roger Riggs 2025-04-10 19:19:31 +00:00
parent 60f3d60741
commit af5db51306
17 changed files with 46 additions and 28 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -67,7 +67,7 @@ import sun.security.util.SecurityConstants;
* <P>
* The actions string is converted to lowercase before processing.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -83,6 +83,7 @@ import sun.security.util.SecurityConstants;
* @serial exclude
*/
@Deprecated(since="25", forRemoval=true)
public final class FilePermission extends Permission implements Serializable {
/**
@ -1115,6 +1116,7 @@ final class FilePermissionCollection extends PermissionCollection
* has been marked readonly
*/
@Override
@SuppressWarnings("removal")
public void add(Permission permission) {
if (! (permission instanceof FilePermission fp))
throw new IllegalArgumentException("invalid permission: "+
@ -1152,6 +1154,7 @@ final class FilePermissionCollection extends PermissionCollection
* the set, false if not.
*/
@Override
@SuppressWarnings("removal")
public boolean implies(Permission permission) {
if (! (permission instanceof FilePermission fperm))
return false;
@ -1180,6 +1183,7 @@ final class FilePermissionCollection extends PermissionCollection
* @return an enumeration of all the FilePermission objects.
*/
@Override
@SuppressWarnings("removal")
public Enumeration<Permission> elements() {
return perms.elements();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 2025, 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
@ -186,6 +186,7 @@ public interface ObjectStreamConstants {
* @see java.io.ObjectInputStream#enableResolveObject(boolean)
* @since 1.2
*/
@SuppressWarnings("removal")
static final SerializablePermission SUBSTITUTION_PERMISSION =
new SerializablePermission("enableSubstitution");
@ -196,6 +197,7 @@ public interface ObjectStreamConstants {
* @see java.io.ObjectInputStream#readObjectOverride()
* @since 1.2
*/
@SuppressWarnings("removal")
static final SerializablePermission SUBCLASS_IMPLEMENTATION_PERMISSION =
new SerializablePermission("enableSubclassImplementation");
@ -205,6 +207,7 @@ public interface ObjectStreamConstants {
* @see java.io.ObjectInputFilter.Config#setSerialFilter(ObjectInputFilter)
* @since 9
*/
@SuppressWarnings("removal")
static final SerializablePermission SERIAL_FILTER_PERMISSION =
new SerializablePermission("serialFilter");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -36,7 +36,7 @@ import java.util.StringTokenizer;
* no actions list; you either have the named permission
* or you don't.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -51,6 +51,7 @@ import java.util.StringTokenizer;
/* code was borrowed originally from java.lang.RuntimePermission. */
@Deprecated(since="25", forRemoval=true)
public final class SerializablePermission extends BasicPermission {
@java.io.Serial

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -38,7 +38,7 @@ import java.security.*;
* An asterisk may appear at the end of the name, following a ".",
* or by itself, to signify a wildcard match. For example: "loadLibrary.*"
* and "*" signify a wildcard match, while "*loadLibrary" and "a*b" do not.
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -53,6 +53,7 @@ import java.security.*;
* @since 1.2
*/
@Deprecated(since="25", forRemoval=true)
public final class RuntimePermission extends BasicPermission {
@java.io.Serial

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -28,7 +28,7 @@ package java.lang.reflect;
/**
* The Permission class for reflective operations.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -38,6 +38,7 @@ package java.lang.reflect;
*
* @since 1.2
*/
@Deprecated(since="25", forRemoval=true)
public final
class ReflectPermission extends java.security.BasicPermission {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2007, 2025, 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
@ -30,12 +30,13 @@ import java.security.BasicPermission;
/**
* The {@code Permission} class for link creation operations.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
* @since 1.7
*/
@Deprecated(since="25", forRemoval=true)
public final class LinkPermission extends BasicPermission {
@java.io.Serial
static final long serialVersionUID = -1441492453772213220L;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2025, 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
@ -54,7 +54,7 @@ import sun.security.util.SecurityConstants;
* <P>
* The actions string is converted to lowercase before processing.
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -70,6 +70,7 @@ import sun.security.util.SecurityConstants;
* @serial exclude
*/
@Deprecated(since="25", forRemoval=true)
public final class PropertyPermission extends BasicPermission {
/**
@ -412,6 +413,7 @@ final class PropertyPermissionCollection extends PermissionCollection
* Key is property name; value is PropertyPermission.
* Not serialized; see serialization section at end of class.
*/
@SuppressWarnings("removal")
private transient ConcurrentHashMap<String, PropertyPermission> perms;
/**
@ -443,6 +445,7 @@ final class PropertyPermissionCollection extends PermissionCollection
* object has been marked readonly
*/
@Override
@SuppressWarnings("removal")
public void add(Permission permission) {
if (! (permission instanceof PropertyPermission pp))
throw new IllegalArgumentException("invalid permission: "+
@ -487,6 +490,7 @@ final class PropertyPermissionCollection extends PermissionCollection
* the set, false if not.
*/
@Override
@SuppressWarnings("removal")
public boolean implies(Permission permission) {
if (! (permission instanceof PropertyPermission pp))
return false;
@ -613,6 +617,7 @@ final class PropertyPermissionCollection extends PermissionCollection
* perms field. Reads in all_allowed.
*/
@java.io.Serial
@SuppressWarnings("removal")
private void readObject(ObjectInputStream in)
throws IOException, ClassNotFoundException
{

View File

@ -1629,12 +1629,6 @@ public class ForkJoinPool extends AbstractExecutorService
*/
private static volatile int poolIds;
/**
* Permission required for callers of methods that may start or
* kill threads. Lazily constructed.
*/
static volatile RuntimePermission modifyThreadPermission;
/**
* For VirtualThread intrinsics
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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
@ -35,6 +35,7 @@ public interface JavaIOFilePermissionAccess {
* @return the new FilePermission plus the alt path (as npath2)
* or the input itself if no alt path is available.
*/
@SuppressWarnings("removal")
FilePermission newPermPlusAltPath(FilePermission input);
/**
@ -44,5 +45,6 @@ public interface JavaIOFilePermissionAccess {
* @return the new FilePermission using the alt path (as npath)
* or null if no alt path is available
*/
@SuppressWarnings("removal")
FilePermission newPermUsingAltPath(FilePermission input);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2025, 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
@ -287,6 +287,7 @@ public class SharedSecrets {
javaIOFileDescriptorAccess = jiofda;
}
@SuppressWarnings("removal")
public static JavaIOFilePermissionAccess getJavaIOFilePermissionAccess() {
var access = javaIOFilePermissionAccess;
if (access == null) {

View File

@ -67,6 +67,7 @@ public final class JrtFileSystemProvider extends FileSystemProvider {
/**
* Need RuntimePermission "accessSystemModules" to create or get jrt:/
*/
@SuppressWarnings("removal")
private void checkPermission() {
@SuppressWarnings({ "removal", "suppression" })
SecurityManager sm = System.getSecurityManager();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1995, 2025, 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
@ -204,6 +204,7 @@ public class FileURLConnection extends URLConnection {
/* since getOutputStream isn't supported, only read permission is
* relevant
*/
@SuppressWarnings("removal")
public Permission getPermission() throws IOException {
if (permission == null) {
String decodedPath = ParseUtil.decode(url.getPath());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2025, 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
@ -60,6 +60,7 @@ public class FilePermCompat {
}
}
@SuppressWarnings("removal")
public static Permission newPermPlusAltPath(Permission input) {
if (compat && input instanceof FilePermission) {
return SharedSecrets.getJavaIOFilePermissionAccess()
@ -68,6 +69,7 @@ public class FilePermCompat {
return input;
}
@SuppressWarnings("removal")
public static Permission newPermUsingAltPath(Permission input) {
if (input instanceof FilePermission) {
return SharedSecrets.getJavaIOFilePermissionAccess()

View File

@ -41,6 +41,7 @@ final class UNCFileURLConnection extends FileURLConnection {
}
@Override
@SuppressWarnings("removal")
public Permission getPermission() {
Permission perm = permission;
if (perm == null) {
@ -49,4 +50,3 @@ final class UNCFileURLConnection extends FileURLConnection {
return perm;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2025, 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
@ -31,7 +31,6 @@ import java.nio.file.CopyOption;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.FileAlreadyExistsException;
import java.nio.file.LinkOption;
import java.nio.file.LinkPermission;
import java.nio.file.StandardCopyOption;
import java.util.concurrent.ExecutionException;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2025, 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
@ -31,7 +31,7 @@ package java.util.logging;
* This class is for logging permissions. Currently there is only one
* LoggingPermission named "control".
*
* @apiNote
* @deprecated
* This permission cannot be used for controlling access to resources
* as the Security Manager is no longer supported.
*
@ -45,6 +45,7 @@ package java.util.logging;
*
*/
@Deprecated(since="25", forRemoval=true)
public final class LoggingPermission extends java.security.BasicPermission {
private static final long serialVersionUID = 63564341580231582L;

View File

@ -438,6 +438,7 @@ public final class TemplatesImpl implements Templates, Serializable {
* Defines the translet class and auxiliary classes.
* Returns a reference to the Class object that defines the main class
*/
@SuppressWarnings("removal")
private void defineTransletClasses()
throws TransformerConfigurationException {