8344077: Remove security manager dependency in java.io

Reviewed-by: rriggs, alanb, naoto, lancea
This commit is contained in:
Brian Burkhalter 2024-11-19 20:30:22 +00:00
parent f6f73ce70d
commit 81e43114ec
9 changed files with 41 additions and 273 deletions

View file

@ -199,23 +199,15 @@ public class FileOutputStream extends OutputStream
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);
}
if (name == null) {
throw new NullPointerException();
}
if (file.isInvalid()) {
throw new FileNotFoundException("Invalid file path");
}
this.path = file.getPath();
this.fd = new FileDescriptor();
fd.attach(this);
this.path = name;
open(name, append);
open(this.path, append);
FileCleanable.register(fd); // open sets the fd, register the cleanup
}
@ -236,14 +228,9 @@ public class FileOutputStream extends OutputStream
*/
@SuppressWarnings("this-escape")
public FileOutputStream(FileDescriptor fdObj) {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (fdObj == null) {
throw new NullPointerException();
}
if (security != null) {
security.checkWrite(fdObj);
}
this.fd = fdObj;
this.path = null;