From ef7002104eb81cec03d790fb81dece6d2f93665c Mon Sep 17 00:00:00 2001
From: Alan Bateman Unlike most methods in this class, this method does not throw
- * security exceptions. If a security manager exists and its {@link
- * SecurityManager#checkRead(String)} method denies read access to a
- * particular root directory, then that directory will not appear in the
- * result.
- *
* @implNote
* Windows platforms, for example, have a root directory
* for each active drive; UNIX platforms have a single root directory,
@@ -1898,12 +1722,6 @@ public static File[] listRoots() {
* abstract pathname does not name a partition or if the size
* cannot be obtained
*
- * @throws SecurityException
- * If a security manager has been installed and it denies
- * {@link RuntimePermission}{@code ("getFileSystemAttributes")}
- * or its {@link SecurityManager#checkRead(String)} method denies
- * read access to the file named by this abstract pathname
- *
* @since 1.6
* @see FileStore#getTotalSpace
*/
@@ -1942,12 +1760,6 @@ public long getTotalSpace() {
* equal to the total file system size returned by
* {@link #getTotalSpace}.
*
- * @throws SecurityException
- * If a security manager has been installed and it denies
- * {@link RuntimePermission}{@code ("getFileSystemAttributes")}
- * or its {@link SecurityManager#checkRead(String)} method denies
- * read access to the file named by this abstract pathname
- *
* @since 1.6
* @see FileStore#getUnallocatedSpace
*/
@@ -1989,12 +1801,6 @@ public long getFreeSpace() {
* is not available, this method will be equivalent to a call to
* {@link #getFreeSpace}.
*
- * @throws SecurityException
- * If a security manager has been installed and it denies
- * {@link RuntimePermission}{@code ("getFileSystemAttributes")}
- * or its {@link SecurityManager#checkRead(String)} method denies
- * read access to the file named by this abstract pathname
- *
* @since 1.6
* @see FileStore#getUsableSpace
*/
@@ -2176,11 +1982,6 @@ static File generateFile(String prefix, String suffix, File dir)
* @throws IOException
* If a file could not be created
*
- * @throws SecurityException
- * If a security manager exists and its {@link
- * java.lang.SecurityManager#checkWrite(java.lang.String)}
- * method does not allow a file to be created
- *
* @since 1.2
*/
public static File createTempFile(String prefix, String suffix,
@@ -2250,11 +2051,6 @@ public static File createTempFile(String prefix, String suffix,
*
* @throws IOException If a file could not be created
*
- * @throws SecurityException
- * If a security manager exists and its {@link
- * java.lang.SecurityManager#checkWrite(java.lang.String)}
- * method does not allow a file to be created
- *
* @since 1.2
* @see java.nio.file.Files#createTempDirectory(String,FileAttribute[])
*/
diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java
index 60b289637fdfc..284f72f8b061c 100644
--- a/src/java.base/share/classes/java/io/FileInputStream.java
+++ b/src/java.base/share/classes/java/io/FileInputStream.java
@@ -91,11 +91,6 @@ public class FileInputStream extends InputStream
* object is created to represent this file
* connection.
*
- * First, if there is a security
- * manager, its {@code checkRead} method
- * is called with the {@code name} argument
- * as its argument.
- *
* If the named file does not exist, is a directory rather than a regular
* file, or for some other reason cannot be opened for reading then a
* {@code FileNotFoundException} is thrown.
@@ -105,10 +100,6 @@ public class FileInputStream extends InputStream
* is a directory rather than a regular file,
* or for some other reason cannot be opened for
* reading.
- * @throws SecurityException if a security manager exists and its
- * {@code checkRead} method denies read access
- * to the file.
- * @see java.lang.SecurityManager#checkRead(java.lang.String)
*/
public FileInputStream(String name) throws FileNotFoundException {
this(name != null ? new File(name) : null);
@@ -124,11 +115,6 @@ public FileInputStream(String name) throws FileNotFoundException {
* A new {@code FileDescriptor} object
* is created to represent this file connection.
*
- * First, if there is a security manager,
- * its {@code checkRead} method is called
- * with the path represented by the {@code file}
- * argument as its argument.
- *
* If the named file does not exist, is a directory rather than a regular
* file, or for some other reason cannot be opened for reading then a
* {@code FileNotFoundException} is thrown.
@@ -138,10 +124,7 @@ public FileInputStream(String name) throws FileNotFoundException {
* is a directory rather than a regular file,
* or for some other reason cannot be opened for
* reading.
- * @throws SecurityException if a security manager exists and its
- * {@code checkRead} method denies read access to the file.
* @see java.io.File#getPath()
- * @see java.lang.SecurityManager#checkRead(java.lang.String)
*/
@SuppressWarnings("this-escape")
public FileInputStream(File file) throws FileNotFoundException {
@@ -169,11 +152,6 @@ public FileInputStream(File file) throws FileNotFoundException {
* {@code fdObj}, which represents an existing connection to an
* actual file in the file system.
*
- * If there is a security manager, its {@code checkRead} method is
- * called with the file descriptor {@code fdObj} as its argument to
- * see if it's ok to read the file descriptor. If read access is denied
- * to the file descriptor a {@code SecurityException} is thrown.
- *
* If {@code fdObj} is null then a {@code NullPointerException}
* is thrown.
*
@@ -183,10 +161,6 @@ public FileInputStream(File file) throws FileNotFoundException {
* I/O on the stream, an {@code IOException} is thrown.
*
* @param fdObj the file descriptor to be opened for reading.
- * @throws SecurityException if a security manager exists and its
- * {@code checkRead} method denies read access to the
- * file descriptor.
- * @see SecurityManager#checkRead(java.io.FileDescriptor)
*/
@SuppressWarnings("this-escape")
public FileInputStream(FileDescriptor fdObj) {
diff --git a/src/java.base/share/classes/java/io/FileOutputStream.java b/src/java.base/share/classes/java/io/FileOutputStream.java
index ff15e831b9530..557bea0c3fc51 100644
--- a/src/java.base/share/classes/java/io/FileOutputStream.java
+++ b/src/java.base/share/classes/java/io/FileOutputStream.java
@@ -103,9 +103,6 @@ public class FileOutputStream extends OutputStream
* A new {@code FileDescriptor} object is
* created to represent this file connection.
*
- * First, if there is a security manager, its {@code checkWrite}
- * method is called with {@code name} as its argument.
- *
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a {@code FileNotFoundException} is thrown.
@@ -118,10 +115,6 @@ public class FileOutputStream extends OutputStream
* @throws FileNotFoundException if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason
- * @throws SecurityException if a security manager exists and its
- * {@code checkWrite} method denies write access
- * to the file.
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
*/
public FileOutputStream(String name) throws FileNotFoundException {
this(name != null ? new File(name) : null, false);
@@ -137,9 +130,6 @@ public FileOutputStream(String name) throws FileNotFoundException {
* A new {@code FileDescriptor} object is created to represent this
* file connection.
*
- * First, if there is a security manager, its {@code checkWrite}
- * method is called with {@code name} as its argument.
- *
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a {@code FileNotFoundException} is thrown.
@@ -150,10 +140,6 @@ public FileOutputStream(String name) throws FileNotFoundException {
* @throws FileNotFoundException if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason.
- * @throws SecurityException if a security manager exists and its
- * {@code checkWrite} method denies write access
- * to the file.
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
* @since 1.1
*/
public FileOutputStream(String name, boolean append)
@@ -171,10 +157,6 @@ public FileOutputStream(String name, boolean append)
* A new {@code FileDescriptor} object is
* created to represent this file connection.
*
- * First, if there is a security manager, its {@code checkWrite}
- * method is called with the path represented by the {@code file}
- * argument as its argument.
- *
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a {@code FileNotFoundException} is thrown.
@@ -183,12 +165,7 @@ public FileOutputStream(String name, boolean append)
* @throws FileNotFoundException if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason
- * @throws SecurityException if a security manager exists and its
- * {@code checkWrite} method denies write access
- * to the file.
* @see java.io.File#getPath()
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
*/
public FileOutputStream(File file) throws FileNotFoundException {
this(file, false);
@@ -205,10 +182,6 @@ public FileOutputStream(File file) throws FileNotFoundException {
* A new {@code FileDescriptor} object is created to represent this
* file connection.
*
- * First, if there is a security manager, its {@code checkWrite}
- * method is called with the path represented by the {@code file}
- * argument as its argument.
- *
* If the file exists but is a directory rather than a regular file, does
* not exist but cannot be created, or cannot be opened for any other
* reason then a {@code FileNotFoundException} is thrown.
@@ -219,12 +192,7 @@ public FileOutputStream(File file) throws FileNotFoundException {
* @throws FileNotFoundException if the file exists but is a directory
* rather than a regular file, does not exist but cannot
* be created, or cannot be opened for any other reason
- * @throws SecurityException if a security manager exists and its
- * {@code checkWrite} method denies write access
- * to the file.
* @see java.io.File#getPath()
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
* @since 1.4
*/
@SuppressWarnings("this-escape")
@@ -256,10 +224,6 @@ public FileOutputStream(File file, boolean append)
* descriptor, which represents an existing connection to an actual
* file in the file system.
*
- * First, if there is a security manager, its {@code checkWrite}
- * method is called with the file descriptor {@code fdObj}
- * argument as its argument.
- *
* If {@code fdObj} is null then a {@code NullPointerException}
* is thrown.
*
@@ -269,10 +233,6 @@ public FileOutputStream(File file, boolean append)
* I/O on the stream, an {@code IOException} is thrown.
*
* @param fdObj the file descriptor to be opened for writing
- * @throws SecurityException if a security manager exists and its
- * {@code checkWrite} method denies
- * write access to the file descriptor
- * @see java.lang.SecurityManager#checkWrite(java.io.FileDescriptor)
*/
@SuppressWarnings("this-escape")
public FileOutputStream(FileDescriptor fdObj) {
diff --git a/src/java.base/share/classes/java/io/FilePermission.java b/src/java.base/share/classes/java/io/FilePermission.java
index 808c42931434d..2f6f73efb14ba 100644
--- a/src/java.base/share/classes/java/io/FilePermission.java
+++ b/src/java.base/share/classes/java/io/FilePermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -61,39 +61,15 @@
* (recursively) all files and subdirectories contained in the current
* directory.
*
- * The actions to be granted are passed to the constructor in a string containing
+ * The actions are passed to the constructor in a string containing
* a list of one or more comma-separated keywords. The possible keywords are
- * "read", "write", "execute", "delete", and "readlink". Their meaning is
- * defined as follows:
- *
- *
* The actions string is converted to lowercase before processing.
- *
- * Be careful when granting FilePermissions. Think about the implications
- * of granting read and especially write access to various files and
- * directories. The {@literal "<
- * Please note: Code can always read a file from the same
- * directory it's in (or a subdirectory of that directory); it does not
- * need explicit permission to do so.
+ *
+ * @apiNote
+ * This permission cannot be used for controlling access to resources anymore
+ * as the Security Manager is no longer supported.
*
* @see java.security.Permission
* @see java.security.Permissions
diff --git a/src/java.base/share/classes/java/io/ObjectInputFilter.java b/src/java.base/share/classes/java/io/ObjectInputFilter.java
index 879820761c129..9a04e1f58e330 100644
--- a/src/java.base/share/classes/java/io/ObjectInputFilter.java
+++ b/src/java.base/share/classes/java/io/ObjectInputFilter.java
@@ -728,8 +728,6 @@ public static ObjectInputFilter getSerialFilter() {
* Set the static JVM-wide filter if it has not already been configured or set.
*
* @param filter the deserialization filter to set as the JVM-wide filter; not null
- * @throws SecurityException if there is security manager and the
- * {@code SerializablePermission("serialFilter")} is not granted
* @throws IllegalStateException if the filter has already been set or the initialization
* of the filter from the system property {@code jdk.serialFilter} or
* the security property {@code jdk.serialFilter} fails.
@@ -829,8 +827,6 @@ static BinaryOperator If a security manager is installed, this constructor will check for
- * the "enableSubclassImplementation" SerializablePermission when invoked
- * directly or indirectly by the constructor of a subclass which overrides
- * the ObjectInputStream.readFields or ObjectInputStream.readUnshared
- * methods.
- *
* @param in input stream to read from
* @throws StreamCorruptedException if the stream header is incorrect
* @throws IOException if an I/O error occurs while reading stream header
- * @throws SecurityException if untrusted subclass illegally overrides
- * security-sensitive methods
* @throws IllegalStateException if the initialization of {@link ObjectInputFilter.Config}
* fails due to invalid serial filter or serial filter factory properties.
* @throws NullPointerException if {@code in} is {@code null}
@@ -419,21 +411,11 @@ public ObjectInputStream(InputStream in) throws IOException {
* When the filter factory {@code apply} method is invoked it may throw a runtime exception
* preventing the {@code ObjectInputStream} from being constructed.
*
- * If there is a security manager installed, this method first calls the
- * security manager's {@code checkPermission} method with the
- * {@code SerializablePermission("enableSubclassImplementation")}
- * permission to ensure it's ok to enable subclassing.
- *
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies enabling
- * subclassing.
* @throws IOException if an I/O error occurs while creating this stream
* @throws IllegalStateException if the initialization of {@link ObjectInputFilter.Config}
* fails due to invalid serial filter or serial filter factory properties.
- * @see SecurityManager#checkPermission
- * @see java.io.SerializablePermission
*/
- protected ObjectInputStream() throws IOException, SecurityException {
+ protected ObjectInputStream() throws IOException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -599,12 +581,6 @@ protected Object readObjectOverride()
* each object (regular or class) read to reconstruct the root object.
* See {@link #setObjectInputFilter(ObjectInputFilter) setObjectInputFilter} for details.
*
- * ObjectInputStream subclasses which override this method can only be
- * constructed in security contexts possessing the
- * "enableSubclassImplementation" SerializablePermission; any attempt to
- * instantiate such a subclass without this permission will cause a
- * SecurityException to be thrown.
- *
* @return reference to deserialized object
* @throws ClassNotFoundException if class of an object to deserialize
* cannot be found
@@ -923,26 +899,11 @@ protected Object resolveObject(Object obj) throws IOException {
* enabled, the {@link #resolveObject} method is called for every object being
* deserialized.
*
- * If object replacement is currently not enabled, and
- * {@code enable} is true, and there is a security manager installed,
- * this method first calls the security manager's
- * {@code checkPermission} method with the
- * {@code SerializablePermission("enableSubstitution")} permission to
- * ensure that the caller is permitted to enable the stream to do replacement
- * of objects read from the stream.
- *
* @param enable true for enabling use of {@code resolveObject} for
* every object being deserialized
* @return the previous setting before this method was invoked
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies enabling the stream
- * to do replacement of objects read from the stream.
- * @see SecurityManager#checkPermission
- * @see java.io.SerializablePermission
*/
- protected boolean enableResolveObject(boolean enable)
- throws SecurityException
- {
+ protected boolean enableResolveObject(boolean enable) {
if (enable == enableResolve) {
return enable;
}
@@ -1341,8 +1302,6 @@ public final ObjectInputFilter getObjectInputFilter() {
* is increased before reading an object.
*
* @param filter the filter, may be null
- * @throws SecurityException if there is security manager and the
- * {@code SerializablePermission("serialFilter")} is not granted
* @throws IllegalStateException if an object has been read,
* if the filter factory returns {@code null} when the
* {@linkplain #getObjectInputFilter() current filter} is non-null, or
diff --git a/src/java.base/share/classes/java/io/ObjectOutputStream.java b/src/java.base/share/classes/java/io/ObjectOutputStream.java
index 3650b10135356..2f1e4bdb5fa76 100644
--- a/src/java.base/share/classes/java/io/ObjectOutputStream.java
+++ b/src/java.base/share/classes/java/io/ObjectOutputStream.java
@@ -230,16 +230,8 @@ protected Boolean computeValue(Class> type) {
* ensure that constructors for receiving ObjectInputStreams will not block
* when reading the header.
*
- * If a security manager is installed, this constructor will check for
- * the "enableSubclassImplementation" SerializablePermission when invoked
- * directly or indirectly by the constructor of a subclass which overrides
- * the ObjectOutputStream.putFields or ObjectOutputStream.writeUnshared
- * methods.
- *
* @param out output stream to write to
* @throws IOException if an I/O error occurs while writing stream header
- * @throws SecurityException if untrusted subclass illegally overrides
- * security-sensitive methods
* @throws NullPointerException if {@code out} is {@code null}
* @since 1.4
* @see ObjectOutputStream#ObjectOutputStream()
@@ -267,19 +259,9 @@ public ObjectOutputStream(OutputStream out) throws IOException {
* ObjectOutputStream to not have to allocate private data just used by
* this implementation of ObjectOutputStream.
*
- * If there is a security manager installed, this method first calls the
- * security manager's {@code checkPermission} method with a
- * {@code SerializablePermission("enableSubclassImplementation")}
- * permission to ensure it's ok to enable subclassing.
- *
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies enabling
- * subclassing.
* @throws IOException if an I/O error occurs while creating this stream
- * @see SecurityManager#checkPermission
- * @see java.io.SerializablePermission
*/
- protected ObjectOutputStream() throws IOException, SecurityException {
+ protected ObjectOutputStream() throws IOException {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -407,12 +389,6 @@ protected void writeObjectOverride(Object obj) throws IOException {
* writeUnshared, and not to any transitively referenced sub-objects in the
* object graph to be serialized.
*
- * ObjectOutputStream subclasses which override this method can only be
- * constructed in security contexts possessing the
- * "enableSubclassImplementation" SerializablePermission; any attempt to
- * instantiate such a subclass without this permission will cause a
- * SecurityException to be thrown.
- *
* @param obj object to write to stream
* @throws NotSerializableException if an object in the graph to be
* serialized does not implement the Serializable interface
@@ -604,26 +580,11 @@ protected Object replaceObject(Object obj) throws IOException {
* enabled, the {@link #replaceObject} method is called for every object being
* serialized.
*
- * If object replacement is currently not enabled, and
- * {@code enable} is true, and there is a security manager installed,
- * this method first calls the security manager's
- * {@code checkPermission} method with the
- * {@code SerializablePermission("enableSubstitution")} permission to
- * ensure that the caller is permitted to enable the stream to do replacement
- * of objects written to the stream.
- *
* @param enable true for enabling use of {@code replaceObject} for
* every object being serialized
* @return the previous setting before this method was invoked
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies enabling the stream
- * to do replacement of objects written to the stream.
- * @see SecurityManager#checkPermission
- * @see java.io.SerializablePermission
*/
- protected boolean enableReplaceObject(boolean enable)
- throws SecurityException
- {
+ protected boolean enableReplaceObject(boolean enable) {
if (enable == enableReplace) {
return enable;
}
diff --git a/src/java.base/share/classes/java/io/PrintStream.java b/src/java.base/share/classes/java/io/PrintStream.java
index 35e2716dbd324..3096f2356f52f 100644
--- a/src/java.base/share/classes/java/io/PrintStream.java
+++ b/src/java.base/share/classes/java/io/PrintStream.java
@@ -249,10 +249,6 @@ public PrintStream(OutputStream out, boolean autoFlush, Charset charset) {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
* @see Charset#defaultCharset()
*
* @since 1.5
@@ -284,11 +280,6 @@ public PrintStream(String fileName) throws FileNotFoundException {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
- *
* @throws UnsupportedEncodingException
* If the named charset is not supported
*
@@ -320,11 +311,6 @@ public PrintStream(String fileName, String csn)
* @throws IOException
* if an I/O error occurs while opening or creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
- *
* @since 10
*/
public PrintStream(String fileName, Charset charset) throws IOException {
@@ -351,10 +337,6 @@ public PrintStream(String fileName, Charset charset) throws IOException {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
* @see Charset#defaultCharset()
*
* @since 1.5
@@ -386,11 +368,6 @@ public PrintStream(File file) throws FileNotFoundException {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
- *
* @throws UnsupportedEncodingException
* If the named charset is not supported
*
@@ -423,11 +400,6 @@ public PrintStream(File file, String csn)
* @throws IOException
* if an I/O error occurs while opening or creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
- *
* @since 10
*/
public PrintStream(File file, Charset charset) throws IOException {
diff --git a/src/java.base/share/classes/java/io/PrintWriter.java b/src/java.base/share/classes/java/io/PrintWriter.java
index 2ed9315ba6a30..55baa2e0a5701 100644
--- a/src/java.base/share/classes/java/io/PrintWriter.java
+++ b/src/java.base/share/classes/java/io/PrintWriter.java
@@ -195,10 +195,6 @@ public PrintWriter(OutputStream out, boolean autoFlush, Charset charset) {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
* @see Charset#defaultCharset()
*
* @since 1.5
@@ -247,11 +243,6 @@ private PrintWriter(Charset charset, File file)
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
- *
* @throws UnsupportedEncodingException
* If the named charset is not supported
*
@@ -282,11 +273,6 @@ public PrintWriter(String fileName, String csn)
* @throws IOException
* if an I/O error occurs while opening or creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(fileName)} denies write
- * access to the file
- *
* @since 10
*/
public PrintWriter(String fileName, Charset charset) throws IOException {
@@ -313,10 +299,6 @@ public PrintWriter(String fileName, Charset charset) throws IOException {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
* @see Charset#defaultCharset()
*
* @since 1.5
@@ -348,11 +330,6 @@ public PrintWriter(File file) throws FileNotFoundException {
* created, or if some other error occurs while opening or
* creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
- *
* @throws UnsupportedEncodingException
* If the named charset is not supported
*
@@ -383,11 +360,6 @@ public PrintWriter(File file, String csn)
* @throws IOException
* if an I/O error occurs while opening or creating the file
*
- * @throws SecurityException
- * If a security manager is present and {@link
- * SecurityManager#checkWrite checkWrite(file.getPath())}
- * denies write access to the file
- *
* @since 10
*/
public PrintWriter(File file, Charset charset) throws IOException {
diff --git a/src/java.base/share/classes/java/io/RandomAccessFile.java b/src/java.base/share/classes/java/io/RandomAccessFile.java
index cf8ae43dc2147..1487764ac4475 100644
--- a/src/java.base/share/classes/java/io/RandomAccessFile.java
+++ b/src/java.base/share/classes/java/io/RandomAccessFile.java
@@ -114,15 +114,6 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* specified for the {@code RandomAccessFile(File,String)} constructor.
*
- *
- * If there is a security manager, its {@code checkRead} method
- * is called with the {@code pathname} argument
- * as its argument to see if read access to the file is allowed.
- * If the mode allows writing, the security manager's
- * {@code checkWrite} method
- * is also called with the {@code pathname} argument
- * as its argument to see if write access to the file is allowed.
- *
* @param pathname the system-dependent pathname string
* @param mode the access mode
* @throws IllegalArgumentException if the mode argument is not equal
@@ -135,13 +126,6 @@ public class RandomAccessFile implements DataOutput, DataInput, Closeable {
* existing, writable regular file and a new regular file of
* that pathname cannot be created, or if some other error
* occurs while opening or creating the file
- * @throws SecurityException if a security manager exists and its
- * {@code checkRead} method denies read access to the file
- * or the mode is {@code "rw"} and the security manager's
- * {@code checkWrite} method denies write access to the file
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkRead(java.lang.String)
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
*/
public RandomAccessFile(String pathname, String mode)
throws FileNotFoundException
@@ -205,13 +189,6 @@ public RandomAccessFile(String pathname, String mode)
* updates to both the file's content and its metadata to be written, which
* generally requires at least one more low-level I/O operation.
*
- * If there is a security manager, its {@code checkRead} method is
- * called with the pathname of the {@code file} argument as its
- * argument to see if read access to the file is allowed. If the mode
- * allows writing, the security manager's {@code checkWrite} method is
- * also called with the pathname of the {@code file} argument to see if
- * write access to the file is allowed.
- *
* @param file the file object
* @param mode the access mode, as described
* above
@@ -225,12 +202,6 @@ public RandomAccessFile(String pathname, String mode)
* an existing, writable regular file and a new regular file of
* that pathname cannot be created, or if some other error
* occurs while opening or creating the file
- * @throws SecurityException if a security manager exists and its
- * {@code checkRead} method denies read access to the file
- * or the mode is {@code "rw"} and the security manager's
- * {@code checkWrite} method denies write access to the file
- * @see java.lang.SecurityManager#checkRead(java.lang.String)
- * @see java.lang.SecurityManager#checkWrite(java.lang.String)
* @see java.nio.channels.FileChannel#force(boolean)
*/
@SuppressWarnings("this-escape")
diff --git a/src/java.base/share/classes/java/io/SerializablePermission.java b/src/java.base/share/classes/java/io/SerializablePermission.java
index 914b5b13dc3bd..3cbfee4dadbec 100644
--- a/src/java.base/share/classes/java/io/SerializablePermission.java
+++ b/src/java.base/share/classes/java/io/SerializablePermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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,55 +36,9 @@
* no actions list; you either have the named permission
* or you don't.
*
- *
- * The target name is the name of the Serializable permission (see below).
- *
- *
- * The following table lists the standard {@code SerializablePermission} target names,
- * and for each provides a description of what the permission allows
- * and a discussion of the risks of granting code the permission.
- *
- * Class loaders may typically be used by security managers to indicate
- * security domains.
- *
* In addition to loading classes, a class loader is also responsible for
* locating resources. A resource is some data (a "{@code .class}" file,
* configuration data, or an image for example) that is identified with an
@@ -424,11 +417,6 @@ String nameAndId() {
*
* @throws IllegalArgumentException if the given name is empty.
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkCreateClassLoader()}
- * method doesn't allow creation of a new class loader.
- *
* @since 9
*/
@SuppressWarnings("this-escape")
@@ -440,10 +428,6 @@ protected ClassLoader(String name, ClassLoader parent) {
* Creates a new class loader using the specified parent class loader for
* delegation.
*
- * If there is a security manager, its {@link
- * SecurityManager#checkCreateClassLoader() checkCreateClassLoader} method
- * is invoked. This may result in a security exception. If there is a security manager, its {@link
- * SecurityManager#checkCreateClassLoader()
- * checkCreateClassLoader} method is invoked. This may result in
- * a security exception. If there is a security manager then its {@code checkPermission}
- * method if first called with a {@code RuntimePermission("getClassLoader")}
- * permission to check that the caller is allowed to get access to the
- * class loader. This method returns {@code null} if the resource is not in this
- * module, the resource is encapsulated and cannot be located by the caller,
- * or access to the resource is denied by the security manager. This method returns {@code null} if the resource is not in this module
+ * or the resource is encapsulated and cannot be located by the caller. If there is a security manager then the class loader created by
- * this method will load classes and resources with privileges that are
- * restricted by the calling context of this method.
- *
+ * "read", "write", "execute", "delete", and "readlink".
*
- *
- *
- *
+ * @apiNote
+ * This permission cannot be used for controlling access to resources anymore
+ * as the Security Manager is no longer supported.
*
* @see java.security.BasicPermission
* @see java.security.Permission
@@ -92,7 +46,6 @@
* @see java.security.PermissionCollection
* @see java.lang.SecurityManager
*
- *
* @author Joe Fialli
* @since 1.2
*/
diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java
index ba88157dc923e..4c41ab0bd6e8a 100644
--- a/src/java.base/share/classes/java/lang/Boolean.java
+++ b/src/java.base/share/classes/java/lang/Boolean.java
@@ -272,8 +272,6 @@ public boolean equals(Object obj) {
*
* @param name the system property name.
* @return the {@code boolean} value of the system property.
- * @throws SecurityException for the same reasons as
- * {@link System#getProperty(String) System.getProperty}
* @see java.lang.System#getProperty(java.lang.String)
* @see java.lang.System#getProperty(java.lang.String, java.lang.String)
*/
diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java
index 48ffeea5289ff..fb68c914d4181 100644
--- a/src/java.base/share/classes/java/lang/Class.java
+++ b/src/java.base/share/classes/java/lang/Class.java
@@ -529,11 +529,6 @@ private static Class> forName(String className, Class> caller)
* by this method fails
* @throws ClassNotFoundException if the class cannot be located by
* the specified class loader
- * @throws SecurityException
- * if a security manager is present, and the {@code loader} is
- * {@code null}, and the caller's class loader is not
- * {@code null}, and the caller does not have the
- * {@link RuntimePermission}{@code ("getClassLoader")}
*
* @see java.lang.Class#forName(String)
* @see java.lang.ClassLoader
@@ -622,16 +617,6 @@ private static native Class> forName0(String name, boolean initialize,
*
* @throws LinkageError if the linkage fails
*
- * @throws SecurityException
- *
- *
- *
- *
- *
- * Permission Target Name
- * What the Permission Allows
- * Risks of Allowing this Permission
- *
- *
- *
- * enableSubclassImplementation
- * Subclass implementation of ObjectOutputStream or ObjectInputStream
- * to override the default serialization or deserialization, respectively,
- * of objects
- * Code can use this to serialize or
- * deserialize classes in a purposefully malfeasant manner. For example,
- * during serialization, malicious code can use this to
- * purposefully store confidential private field data in a way easily accessible
- * to attackers. Or, during deserialization it could, for example, deserialize
- * a class with all its private fields zeroed out.
- *
- *
- *
- * enableSubstitution
- * Substitution of one object for another during
- * serialization or deserialization
- * This is dangerous because malicious code
- * can replace the actual object with one which has incorrect or
- * malignant data.
- *
- *
- *
- * serialFilter
- * Setting a filter for ObjectInputStreams.
- * Code could remove a configured filter and remove protections
- * already established.
- *
- *
- *
* @jls 12.2 Loading of Classes and Interfaces
* @jls 12.3 Linking of Classes and Interfaces
* @since 9
@@ -755,13 +740,6 @@ public static Class> forPrimitiveName(String primitiveName) {
* or if the instantiation fails for some other reason.
* @throws ExceptionInInitializerError if the initialization
* provoked by this method fails.
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*/
@SuppressWarnings("removal")
@CallerSensitive
@@ -1056,15 +1034,7 @@ public String getName() {
*
* @return the class loader that loaded the class or interface
* represented by this {@code Class} object.
- * @throws SecurityException
- * if a security manager is present, and the caller's class loader
- * is not {@code null} and is not the same as or an ancestor of the
- * class loader for the class whose class loader is requested,
- * and the caller does not have the
- * {@link RuntimePermission}{@code ("getClassLoader")}
* @see java.lang.ClassLoader
- * @see SecurityManager#checkPermission
- * @see java.lang.RuntimePermission
*/
@CallerSensitive
@ForceInline // to ensure Reflection.getCallerClass optimization
@@ -1540,30 +1510,10 @@ void setSigners(Object[] signers) {
* @return the immediately enclosing method of the underlying class, if
* that class is a local or anonymous class; otherwise {@code null}.
*
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
* @since 1.5
*/
@CallerSensitive
- public Method getEnclosingMethod() throws SecurityException {
+ public Method getEnclosingMethod() {
EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
if (enclosingInfo == null)
@@ -1696,30 +1646,11 @@ private static Class> toClass(Type o) {
*
* @return the immediately enclosing constructor of the underlying class, if
* that class is a local or anonymous class; otherwise {@code null}.
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
+ *
* @since 1.5
*/
@CallerSensitive
- public Constructor> getEnclosingConstructor() throws SecurityException {
+ public Constructor> getEnclosingConstructor() {
EnclosingMethodInfo enclosingInfo = getEnclosingMethodInfo();
if (enclosingInfo == null)
@@ -1776,16 +1707,10 @@ public Constructor> getEnclosingConstructor() throws SecurityException {
* type, or void, then this method returns null.
*
* @return the declaring class for this class
- * @throws SecurityException
- * If a security manager, s, is present and the caller's
- * class loader is not the same as or an ancestor of the class
- * loader for the declaring class and invocation of {@link
- * SecurityManager#checkPackageAccess s.checkPackageAccess()}
- * denies access to the package of the declaring class
* @since 1.1
*/
@CallerSensitive
- public Class> getDeclaringClass() throws SecurityException {
+ public Class> getDeclaringClass() {
final Class> candidate = getDeclaringClass0();
if (candidate != null) {
@@ -1807,16 +1732,10 @@ public Class> getDeclaringClass() throws SecurityException {
* class. If the underlying class is a top level class this
* method returns {@code null}.
* @return the immediately enclosing class of the underlying class
- * @throws SecurityException
- * If a security manager, s, is present and the caller's
- * class loader is not the same as or an ancestor of the class
- * loader for the enclosing class and invocation of {@link
- * SecurityManager#checkPackageAccess s.checkPackageAccess()}
- * denies access to the package of the enclosing class
* @since 1.5
*/
@CallerSensitive
- public Class> getEnclosingClass() throws SecurityException {
+ public Class> getEnclosingClass() {
// There are five kinds of classes (or interfaces):
// a) Top level classes
// b) Nested classes (static member classes)
@@ -2071,14 +1990,6 @@ private boolean hasEnclosingMethodInfo() {
*
* @return the array of {@code Class} objects representing the public
* members of this class
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
- *
* @since 1.1
*/
@SuppressWarnings("removal")
@@ -2139,20 +2050,13 @@ public Class>[] run() {
*
* @return the array of {@code Field} objects representing the
* public fields
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*
* @since 1.1
* @jls 8.2 Class Members
* @jls 8.3 Field Declarations
*/
@CallerSensitive
- public Field[] getFields() throws SecurityException {
+ public Field[] getFields() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2230,20 +2134,13 @@ public Field[] getFields() throws SecurityException {
*
* @return the array of {@code Method} objects representing the
* public methods of this class
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*
* @jls 8.2 Class Members
* @jls 8.4 Method Declarations
* @since 1.1
*/
@CallerSensitive
- public Method[] getMethods() throws SecurityException {
+ public Method[] getMethods() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2273,19 +2170,12 @@ public Method[] getMethods() throws SecurityException {
*
* @return the array of {@code Constructor} objects representing the
* public constructors of this class
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*
* @see #getDeclaredConstructors()
* @since 1.1
*/
@CallerSensitive
- public Constructor>[] getConstructors() throws SecurityException {
+ public Constructor>[] getConstructors() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2325,21 +2215,13 @@ public Constructor>[] getConstructors() throws SecurityException {
* @throws NoSuchFieldException if a field with the specified name is
* not found.
* @throws NullPointerException if {@code name} is {@code null}
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*
* @since 1.1
* @jls 8.2 Class Members
* @jls 8.3 Field Declarations
*/
@CallerSensitive
- public Field getField(String name)
- throws NoSuchFieldException, SecurityException {
+ public Field getField(String name) throws NoSuchFieldException {
Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
@@ -2436,13 +2318,6 @@ public Field getField(String name)
* or if the name is {@value ConstantDescs#INIT_NAME} or
* {@value ConstantDescs#CLASS_INIT_NAME}.
* @throws NullPointerException if {@code name} is {@code null}
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
*
* @jls 8.2 Class Members
* @jls 8.4 Method Declarations
@@ -2450,7 +2325,7 @@ public Field getField(String name)
*/
@CallerSensitive
public Method getMethod(String name, Class>... parameterTypes)
- throws NoSuchMethodException, SecurityException {
+ throws NoSuchMethodException {
Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
@@ -2485,21 +2360,13 @@ public Method getMethod(String name, Class>... parameterTypes)
* @throws NoSuchMethodException if a matching constructor is not found,
* including when this {@code Class} object represents
* an interface, a primitive type, an array class, or void.
- * @throws SecurityException
- * If a security manager, s, is present and
- * the caller's class loader is not the same as or an
- * ancestor of the class loader for the current class and
- * invocation of {@link SecurityManager#checkPackageAccess
- * s.checkPackageAccess()} denies access to the package
- * of this class.
- *
- * @see #getDeclaredConstructor(Class>[])
+ *
+ * @see #getDeclaredConstructor(Class[])
* @since 1.1
*/
@CallerSensitive
public Constructor
- *
- *
*
* @since 1.1
* @jls 8.5 Member Class and Interface Declarations
*/
@CallerSensitive
- public Class>[] getDeclaredClasses() throws SecurityException {
+ public Class>[] getDeclaredClasses() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2574,33 +2421,13 @@ public Class>[] getDeclaredClasses() throws SecurityException {
*
* @return the array of {@code Field} objects representing all the
* declared fields of this class
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @since 1.1
* @jls 8.2 Class Members
* @jls 8.3 Field Declarations
*/
@CallerSensitive
- public Field[] getDeclaredFields() throws SecurityException {
+ public Field[] getDeclaredFields() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2637,26 +2464,6 @@ public Field[] getDeclaredFields() throws SecurityException {
* @return An array of {@code RecordComponent} objects representing all the
* record components of this record class, or {@code null} if this
* class is not a record class
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @jls 8.10 Record Classes
* @since 16
@@ -2705,26 +2512,6 @@ public RecordComponent[] getRecordComponents() {
*
* @return the array of {@code Method} objects representing all the
* declared methods of this class
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @jls 8.2 Class Members
* @jls 8.4 Method Declarations
@@ -2734,7 +2521,7 @@ public RecordComponent[] getRecordComponents() {
* @since 1.1
*/
@CallerSensitive
- public Method[] getDeclaredMethods() throws SecurityException {
+ public Method[] getDeclaredMethods() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2759,33 +2546,13 @@ public Method[] getDeclaredMethods() throws SecurityException {
*
* @return the array of {@code Constructor} objects representing all the
* declared constructors of this class
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @since 1.1
* @see #getConstructors()
* @jls 8.8 Constructor Declarations
*/
@CallerSensitive
- public Constructor>[] getDeclaredConstructors() throws SecurityException {
+ public Constructor>[] getDeclaredConstructors() {
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
@@ -2810,34 +2577,13 @@ public Constructor>[] getDeclaredConstructors() throws SecurityException {
* @throws NoSuchFieldException if a field with the specified name is
* not found.
* @throws NullPointerException if {@code name} is {@code null}
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @since 1.1
* @jls 8.2 Class Members
* @jls 8.3 Field Declarations
*/
@CallerSensitive
- public Field getDeclaredField(String name)
- throws NoSuchFieldException, SecurityException {
+ public Field getDeclaredField(String name) throws NoSuchFieldException {
Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
@@ -2876,26 +2622,6 @@ public Field getDeclaredField(String name)
* matching the specified name and parameters
* @throws NoSuchMethodException if a matching method is not found.
* @throws NullPointerException if {@code name} is {@code null}
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
*
* @jls 8.2 Class Members
* @jls 8.4 Method Declarations
@@ -2903,7 +2629,7 @@ public Field getDeclaredField(String name)
*/
@CallerSensitive
public Method getDeclaredMethod(String name, Class>... parameterTypes)
- throws NoSuchMethodException, SecurityException {
+ throws NoSuchMethodException {
Objects.requireNonNull(name);
@SuppressWarnings("removal")
SecurityManager sm = System.getSecurityManager();
@@ -2974,34 +2700,13 @@ Method findMethod(boolean publicOnly, String name, Class>... parameterTypes) {
* @throws NoSuchMethodException if a matching constructor is not found,
* including when this {@code Class} object represents
* an interface, a primitive type, an array class, or void.
- * @throws SecurityException
- * If a security manager, s, is present and any of the
- * following conditions is met:
- *
- *
- *
- *
- *
- * @see #getConstructor(Class>[])
+ * @see #getConstructor(Class[])
* @since 1.1
*/
@CallerSensitive
public Constructor
If there is a security manager then the class loaders created by - * this method will load classes and resources with privileges that are - * restricted by the calling context of this method.
- * * @param cf * The configuration for the layer * @param parentLayers @@ -586,11 +563,6 @@ public static Controller defineModulesWithOneLoader(Configuration cf, * named "{@code java}" or a package with a name starting with * "{@code java.}" * - * @throws SecurityException - * If {@code RuntimePermission("createClassLoader")} or - * {@code RuntimePermission("getClassLoader")} is denied by - * the security manager - * * @see #findLoader */ public static Controller defineModulesWithManyLoaders(Configuration cf, @@ -673,9 +645,6 @@ public static Controller defineModulesWithManyLoaders(Configuration cf, * configuration of the parent layers, including order * @throws LayerInstantiationException * If creating the layer fails for any of the reasons listed above - * @throws SecurityException - * If {@code RuntimePermission("getClassLoader")} is denied by - * the security manager */ public static Controller defineModules(Configuration cf, ListIf there is a security manager then its {@code checkPermission} - * method is called with a {@code RuntimePermission("getClassLoader")} - * permission to check that the caller is allowed to get access to the - * class loader.
- * * @apiNote This method does not return an {@code OptionalThe returned map is typically case-sensitive on all platforms. * - *
If a security manager exists, its - * {@link SecurityManager#checkPermission checkPermission} method - * is called with a - * {@link RuntimePermission}{@code ("getenv.*")} permission. - * This may result in a {@link SecurityException} being thrown. - * *
When passing information to a Java subprocess, * system properties * are generally preferred over environment variables. * * @return this process builder's environment * - * @throws SecurityException - * if a security manager exists and its - * {@link SecurityManager#checkPermission checkPermission} - * method doesn't allow access to the process environment - * * @see Runtime#exec(String[],String[],java.io.File) * @see System#getenv() */ @@ -1009,12 +998,6 @@ public ProcessBuilder redirectErrorStream(boolean redirectErrorStream) { * The minimal set of system dependent environment variables * may override the values provided in the environment. * - *
If there is a security manager, its - * {@link SecurityManager#checkExec checkExec} - * method is called with the first component of this object's - * {@code command} array as its argument. This may result in - * a {@link SecurityException} being thrown. - * *
Starting an operating system process is highly system-dependent. * Among the many things that can go wrong are: *
- * If there is a security manager, its - * {@link SecurityManager#checkExec checkExec} - * method is called with the first component of each process builder's - * {@code command} array as its argument. This may result in - * a {@link SecurityException} being thrown. - *
* Starting an operating system process is highly system-dependent. * Among the many things that can go wrong are: *
- * The factory methods limit access to ProcessHandles using the
- * SecurityManager checking the {@link RuntimePermission RuntimePermission("manageProcess")}.
- * The ability to control processes is also restricted by the native system,
+ * The ability to control processes may be restricted by the native system,
* ProcessHandle provides no more access to, or control over, the native process
* than would be allowed by a native application.
*
@@ -113,8 +111,6 @@ public interface ProcessHandle extends Comparable The argument serves as a status code. By convention, a nonzero status code
* indicates abnormal termination.
@@ -169,13 +169,6 @@ private Runtime() {}
* Termination status. By convention, a nonzero status code
* indicates abnormal termination.
*
- * @throws SecurityException
- * If a security manager is present and its
- * {@link SecurityManager#checkExit checkExit} method does not permit
- * exiting with the specified status
- *
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkExit(int)
* @see #addShutdownHook
* @see #removeShutdownHook
* @see #halt(int)
@@ -233,10 +226,6 @@ public void exit(int status) {
* @throws IllegalStateException
* If the shutdown sequence has already begun
*
- * @throws SecurityException
- * If a security manager is present and it denies
- * {@link RuntimePermission}{@code ("shutdownHooks")}
- *
* @see #removeShutdownHook
* @see #halt(int)
* @see #exit(int)
@@ -265,10 +254,6 @@ public void addShutdownHook(Thread hook) {
* @throws IllegalStateException
* If the shutdown sequence has already begun
*
- * @throws SecurityException
- * If a security manager is present and it denies
- * {@link RuntimePermission}{@code ("shutdownHooks")}
- *
* @see #addShutdownHook
* @see #exit(int)
* @since 1.3
@@ -284,8 +269,7 @@ public boolean removeShutdownHook(Thread hook) {
/**
* Immediately {@linkplain ##termination terminates} the Java Virtual Machine.
- * If the security manager denies exiting, throws {@link SecurityException}.
- * Otherwise, termination of the Java Virtual Machine is unconditional and immediate.
+ * Termination of the Java Virtual Machine is unconditional and immediate.
* This method does not initiate the {@linkplain ##shutdown shutdown sequence}, nor does
* it wait for the shutdown sequence to finish if it is already in progress. An
* invocation of this method never returns normally.
@@ -303,11 +287,6 @@ public boolean removeShutdownHook(Thread hook) {
* has already been invoked then this status code
* will override the status code passed to that method.
*
- * @throws SecurityException
- * If a security manager is present and its
- * {@link SecurityManager#checkExit checkExit} method
- * does not permit an exit with the specified status
- *
* @see #exit
* @see #addShutdownHook
* @see #removeShutdownHook
@@ -341,11 +320,6 @@ public void halt(int status) {
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws IOException
* If an I/O error occurs
*
@@ -392,11 +366,6 @@ public Process exec(String command) throws IOException {
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws IOException
* If an I/O error occurs
*
@@ -457,11 +426,6 @@ public Process exec(String command, String[] envp) throws IOException {
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws IOException
* If an I/O error occurs
*
@@ -505,11 +469,6 @@ public Process exec(String command, String[] envp, File dir)
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws IOException
* If an I/O error occurs
*
@@ -551,11 +510,6 @@ public Process exec(String[] cmdarray) throws IOException {
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws IOException
* If an I/O error occurs
*
@@ -610,12 +564,6 @@ public Process exec(String[] cmdarray, String[] envp) throws IOException {
* If {@code dir} is {@code null}, the subprocess inherits the
* current working directory of the current process.
*
- * If a security manager exists, its
- * {@link SecurityManager#checkExec checkExec}
- * method is invoked with the first component of the array
- * {@code cmdarray} as its argument. This may result in a
- * {@link SecurityException} being thrown.
- *
* Starting an operating system process is highly system-dependent.
* Among the many things that can go wrong are:
*
- * First, if there is a security manager, its {@code checkLink}
- * method is called with the {@code filename} as its argument.
- * This may result in a security exception.
- *
* This is similar to the method {@link #loadLibrary(String)}, but it
* accepts a general file name as an argument rather than just a library
* name, allowing any file of native code to be loaded.
@@ -820,9 +759,6 @@ public void runFinalization() {
* convenient means of invoking this method.
*
* @param filename the file to load.
- * @throws SecurityException if a security manager exists and its
- * {@code checkLink} method doesn't allow
- * loading of the specified dynamic library
* @throws UnsatisfiedLinkError if either the filename is not an
* absolute path name, the native library is not statically
* linked with the VM, or the library cannot be mapped to
@@ -833,8 +769,6 @@ public void runFinalization() {
* does not have native access enabled.
* @spec jni/index.html Java Native Interface Specification
* @see java.lang.Runtime#getRuntime()
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkLink(java.lang.String)
*/
@CallerSensitive
@Restricted
@@ -871,10 +805,6 @@ void load0(Class> fromClass, String filename) {
* location and mapped to a native library image in an
* implementation-dependent manner.
*
- * First, if there is a security manager, its {@code checkLink}
- * method is called with the {@code libname} as its argument.
- * This may result in a security exception.
- *
* The method {@link System#loadLibrary(String)} is the conventional
* and convenient means of invoking this method. If native
* methods are to be used in the implementation of a class, a standard
@@ -891,9 +821,6 @@ void load0(Class> fromClass, String filename) {
* name, the second and subsequent calls are ignored.
*
* @param libname the name of the library.
- * @throws SecurityException if a security manager exists and its
- * {@code checkLink} method doesn't allow
- * loading of the specified dynamic library
* @throws UnsatisfiedLinkError if either the libname argument
* contains a file path, the native library is not statically
* linked with the VM, or the library cannot be mapped to a
@@ -903,8 +830,6 @@ void load0(Class> fromClass, String filename) {
* @throws IllegalCallerException if the caller is in a module that
* does not have native access enabled.
* @spec jni/index.html Java Native Interface Specification
- * @see java.lang.SecurityException
- * @see java.lang.SecurityManager#checkLink(java.lang.String)
*/
@CallerSensitive
@Restricted
diff --git a/src/java.base/share/classes/java/lang/RuntimePermission.java b/src/java.base/share/classes/java/lang/RuntimePermission.java
index 39996bdd95374..9da02e12794e5 100644
--- a/src/java.base/share/classes/java/lang/RuntimePermission.java
+++ b/src/java.base/share/classes/java/lang/RuntimePermission.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2024, 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
@@ -26,361 +26,21 @@
package java.lang;
import java.security.*;
-import java.lang.module.ModuleFinder;
/**
* This class is for runtime permissions. A {@code RuntimePermission}
* contains a name (also referred to as a "target name") but no actions
* list; you either have the named permission or you don't.
*
- * The target name is the name of the runtime permission (see below). The
- * naming convention follows the hierarchical property naming convention.
- * Also, an asterisk may appear at the end of the name, following a ".",
+ * The target name is the name of the runtime permission. The naming convention
+ * follows the hierarchical property naming convention, typically the reverse
+ * domain name notation, to avoid name clashes.
+ * 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.
- *
- * The following table lists the standard {@code RuntimePermission}
- * target names, and for each provides a description of what the permission
- * allows and a discussion of the risks of granting code the permission.
- *
- * This exception was originally specified for use with a SecurityManager when
+ * an operation was denied. This feature no longer exists. This exception may be
+ * deprecated in a future release.
*
- * @see java.lang.SecurityManager
* @since 1.0
*/
public class SecurityException extends RuntimeException {
diff --git a/src/java.base/share/classes/java/lang/SecurityManager.java b/src/java.base/share/classes/java/lang/SecurityManager.java
index 7e3e43381276d..a76b62328d1fe 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, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2024, 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,332 +25,31 @@
package java.lang;
-import java.lang.module.ModuleDescriptor;
-import java.lang.module.ModuleDescriptor.Exports;
-import java.lang.module.ModuleDescriptor.Opens;
import java.io.FileDescriptor;
-import java.io.File;
-import java.io.FilePermission;
import java.net.InetAddress;
-import java.net.SocketPermission;
-import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.Permission;
-import java.security.PrivilegedAction;
-import java.security.Security;
-import java.security.SecurityPermission;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Objects;
-import java.util.PropertyPermission;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-
-import jdk.internal.module.ModuleLoaderMap;
-import sun.security.util.SecurityConstants;
/**
- * The security manager is a class that allows
- * applications to implement a security policy. It allows an
- * application to determine, before performing a possibly unsafe or
- * sensitive operation, what the operation is and whether
- * it is being attempted in a security context that allows the
- * operation to be performed. The
- * application can allow or disallow the operation.
- *
- * The {@code SecurityManager} class contains many methods with
- * names that begin with the word {@code check}. These methods
- * are called by various methods in the Java libraries before those
- * methods perform certain potentially sensitive operations. The
- * invocation of such a {@code check} method typically looks like this:
- *
- * The security manager is thereby given an opportunity to prevent
- * completion of the operation by throwing an exception. A security
- * manager routine simply returns if the operation is permitted, but
- * throws a {@code SecurityException} if the operation is not
- * permitted.
- *
- * The Java run-time may also allow, but is not required to allow, the security
- * manager to be set dynamically by invoking the
- * {@link System#setSecurityManager(SecurityManager) setSecurityManager} method.
- * In the JDK implementation, if the Java virtual machine is started with
- * the {@code java.security.manager} system property set to the special token
- * "{@code allow}", then a security manager will not be set at startup but can
- * be set dynamically. If the Java virtual machine is started with the
- * {@code java.security.manager} system property not set or set to the special
- * token "{@code disallow}", then a security manager will not be set at startup
- * and cannot be set dynamically (the
- * {@link System#setSecurityManager(SecurityManager) setSecurityManager}
- * method will throw an {@code UnsupportedOperationException}). Finally, if the
- * {@code java.security.manager} system property is set to the class name of
- * the security manager, or to the empty String ("") or the special token
- * "{@code default}", then a security manager is set at startup (as described
- * previously) and can also be subsequently replaced (or disabled) dynamically
- * (subject to the policy of the currently installed security manager). The
- * following table illustrates the behavior of the JDK implementation for the
- * different settings of the {@code java.security.manager} system property:
- *
- * The current security manager is returned by the
- * {@link System#getSecurityManager() getSecurityManager} method.
- *
- * If a requested access is allowed,
- * {@code checkPermission} returns quietly. If denied, a
- * {@code SecurityException} is thrown.
- *
- * The default implementation of each of the other
- * {@code check} methods in {@code SecurityManager} is to
- * call the {@code SecurityManager checkPermission} method
- * to determine if the calling thread has permission to perform the requested
- * operation.
- *
- * Note that the {@code checkPermission} method with
- * just a single permission argument always performs security checks
- * within the context of the currently executing thread.
- * Sometimes a security check that should be made within a given context
- * will actually need to be done from within a
- * different context (for example, from within a worker thread).
- * The {@link SecurityManager#getSecurityContext getSecurityContext} method
- * and the {@link SecurityManager#checkPermission(java.security.Permission,
- * java.lang.Object) checkPermission}
- * method that includes a context argument are provided
- * for this situation. The
- * {@code getSecurityContext} method returns a "snapshot"
- * of the current calling context. (The default implementation
- * returns an AccessControlContext object.) A sample call is
- * the following:
- *
- *
- * The {@code checkPermission} method
- * that takes a context object in addition to a permission
- * makes access decisions based on that context,
- * rather than on that of the current execution thread.
- * Code within a different context can thus call that method,
- * passing the permission and the
- * previously-saved context object. A sample call, using the
- * SecurityManager {@code sm} obtained as in the previous example,
- * is the following:
- *
- * Permissions fall into these categories: File, Socket, Net,
- * Security, Runtime, Property, AWT, Reflect, and Serializable.
- * The classes managing these various
- * permission categories are {@code java.io.FilePermission},
- * {@code java.net.SocketPermission},
- * {@code java.net.NetPermission},
- * {@code java.security.SecurityPermission},
- * {@code java.lang.RuntimePermission},
- * {@code java.util.PropertyPermission},
- * {@code java.awt.AWTPermission},
- * {@code java.lang.reflect.ReflectPermission}, and
- * {@code java.io.SerializablePermission}.
- *
- * All but the first two (FilePermission and SocketPermission) are
- * subclasses of {@code java.security.BasicPermission}, which itself
- * is an abstract subclass of the
- * top-level class for permissions, which is
- * {@code java.security.Permission}. BasicPermission defines the
- * functionality needed for all permissions that contain a name
- * that follows the hierarchical property naming convention
- * (for example, "exitVM", "setFactory", "queuePrintJob", etc).
- * An asterisk
- * may appear at the end of the name, following a ".", or by itself, to
- * signify a wildcard match. For example: "a.*" or "*" is valid,
- * "*a" or "a*b" is not valid.
- *
- * FilePermission and SocketPermission are subclasses of the
- * top-level class for permissions
- * ({@code java.security.Permission}). Classes like these
- * that have a more complicated name syntax than that used by
- * BasicPermission subclass directly from Permission rather than from
- * BasicPermission. For example,
- * for a {@code java.io.FilePermission} object, the permission name is
- * the path name of a file (or directory).
- *
- * Some of the permission classes have an "actions" list that tells
- * the actions that are permitted for the object. For example,
- * for a {@code java.io.FilePermission} object, the actions list
- * (such as "read, write") specifies which actions are granted for the
- * specified file (or for files in the specified directory).
- *
- * Other permission classes are for "named" permissions -
- * ones that contain a name but no actions list; you either have the
- * named permission or you don't.
- *
- * Note: There is also a {@code java.security.AllPermission}
- * permission that implies all permissions. It exists to simplify the work
- * of system administrators who might need to perform multiple
- * tasks that require all (or numerous) permissions.
- *
- * See {@extLink security_guide_permissions
- * Permissions in the Java Development Kit (JDK)}
- * for permission-related information.
- * This document includes a table listing the various SecurityManager
- * {@code check} methods and the permission(s) the default
- * implementation of each such method requires.
- * It also contains a table of the methods
- * that require permissions, and for each such method tells
- * which permission it requires.
- *
- * @author Arthur van Hoff
- * @author Roland Schemers
- *
- * @see java.lang.ClassLoader
- * @see java.lang.SecurityException
- * @see java.lang.System#getSecurityManager() getSecurityManager
- * @see java.lang.System#setSecurityManager(java.lang.SecurityManager)
- * setSecurityManager
- * @see java.security.AccessController AccessController
- * @see java.security.AccessControlContext AccessControlContext
- * @see java.security.AccessControlException AccessControlException
- * @see java.security.Permission
- * @see java.security.BasicPermission
- * @see java.io.FilePermission
- * @see java.net.SocketPermission
- * @see java.util.PropertyPermission
- * @see java.lang.RuntimePermission
- * @see java.security.Policy Policy
- * @see java.security.SecurityPermission SecurityPermission
- * @see java.security.ProtectionDomain
+ * SecurityManager was originally specified to allow an application implement
+ * a security policy. It allowed an application to determine, before performing
+ * a possibly unsafe or security sensitive operation, whether the operation was
+ * being attempted in a security context that allowed the operation.
+ * This feature no longer exists.
*
* @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.
+ * @deprecated There is no replacement for this class.
* See JEP 411 for
* discussion and alternatives.
*/
@Deprecated(since="17", forRemoval=true)
public class SecurityManager {
- /*
- * Have we been initialized. Effective against finalizer attacks.
- */
- private boolean initialized = false;
-
/**
- * Constructs a new {@code SecurityManager}.
- *
- * If there is a security manager already installed, this method first
- * calls the security manager's {@code checkPermission} method
- * with the {@code RuntimePermission("createSecurityManager")}
- * permission to ensure the calling thread has permission to create a new
- * security manager.
- * This may result in throwing a {@code SecurityException}.
- *
- * @throws java.lang.SecurityException if a security manager already
- * exists and its {@code checkPermission} method
- * doesn't allow creation of a new security manager.
- * @see java.lang.System#getSecurityManager()
- * @see #checkPermission(java.security.Permission) checkPermission
- * @see java.lang.RuntimePermission
+ * Constructs a new {@code SecurityManager}. Setting a security manager with
+ * {@link System#setSecurityManager(SecurityManager)} is not supported.
*/
- public SecurityManager() {
- synchronized(SecurityManager.class) {
- @SuppressWarnings("removal")
- SecurityManager sm = System.getSecurityManager();
- if (sm != null) {
- // ask the currently installed security manager if we
- // can create a new one.
- sm.checkPermission(new RuntimePermission
- ("createSecurityManager"));
- }
- initialized = true;
- }
- }
+ public SecurityManager() { }
/**
* Returns the current execution stack as an array of classes.
@@ -361,30 +60,34 @@ public SecurityManager() {
* the class of that method's caller, and so on.
*
* @return the execution stack.
+ * @see StackWalker
*/
- protected native Class>[] getClassContext();
+ protected Class>[] getClassContext() {
+ return StackWalkerHolder.STACK_WALKER
+ .walk(s -> s.map(StackWalker.StackFrame::getDeclaringClass)
+ .toArray(Class[]::new));
+ }
+
+ private static class StackWalkerHolder {
+ static final StackWalker STACK_WALKER =
+ StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
+ }
/**
- * Creates an object that encapsulates the current execution
- * environment. The result of this method is used, for example, by the
- * three-argument {@code checkConnect} method and by the
- * two-argument {@code checkRead} method.
- * These methods are needed because a trusted method may be called
- * on to read a file or open a socket on behalf of another method.
- * The trusted method needs to determine if the other (possibly
- * untrusted) method would be allowed to perform the operation on its
- * own.
- * The default implementation of this method is to return
- * an {@code AccessControlContext} object.
+ * Returns an {@code AccessControlContext} where the {@code checkPermission}
+ * method always throws an {@code AccessControlException} and the
+ * {@code getDomainCombiner} method always returns {@code null}.
*
- * @return an implementation-dependent object that encapsulates
- * sufficient information about the current execution environment
- * to perform some security checks later.
- * @see java.lang.SecurityManager#checkConnect(java.lang.String, int,
- * java.lang.Object) checkConnect
- * @see java.lang.SecurityManager#checkRead(java.lang.String,
- * java.lang.Object) checkRead
+ * @return an {@code AccessControlContext} as specified above
* @see java.security.AccessControlContext AccessControlContext
+ * @apiNote This method originally returned a snapshot of the current
+ * calling context, which included the current thread's access
+ * control context and any limited privilege scope. This method has
+ * been changed to always return an innocuous
+ * {@code AccessControlContext} that fails all permission checks.
+ * {@linkplain SecurityManager The Security Manager} is no longer
+ * supported. There is no replacement for the Security Manager or
+ * this method.
*/
@SuppressWarnings("removal")
public Object getSecurityContext() {
@@ -392,1144 +95,289 @@ public Object getSecurityContext() {
}
/**
- * Throws a {@code SecurityException} if the requested
- * access, specified by the given permission, is not permitted based
- * on the security policy currently in effect.
- *
- * This method calls {@code AccessController.checkPermission}
- * with the given permission.
+ * Throws {@code SecurityException}.
*
- * @param perm the requested permission.
- * @throws SecurityException if access is not permitted based on
- * the current security policy.
- * @throws NullPointerException if the permission argument is
- * {@code null}.
+ * @param perm ignored
+ * @throws SecurityException always
* @since 1.2
*/
- @SuppressWarnings("removal")
public void checkPermission(Permission perm) {
- java.security.AccessController.checkPermission(perm);
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * specified security context is denied access to the resource
- * specified by the given permission.
- * The context must be a security
- * context returned by a previous call to
- * {@code getSecurityContext} and the access control
- * decision is based upon the configured security policy for
- * that security context.
- *
- * If {@code context} is an instance of
- * {@code AccessControlContext} then the
- * {@code AccessControlContext.checkPermission} method is
- * invoked with the specified permission.
- *
- * If {@code context} is not an instance of
- * {@code AccessControlContext} then a
- * {@code SecurityException} is thrown.
+ * Throws {@code SecurityException}.
*
- * @param perm the specified permission
- * @param context a system-dependent security context.
- * @throws SecurityException if the specified security context
- * is not an instance of {@code AccessControlContext}
- * (e.g., is {@code null}), or is denied access to the
- * resource specified by the given permission.
- * @throws NullPointerException if the permission argument is
- * {@code null}.
- * @see java.lang.SecurityManager#getSecurityContext()
- * @see java.security.AccessControlContext#checkPermission(java.security.Permission)
+ * @param perm ignored
+ * @param context ignored
+ * @throws SecurityException always
* @since 1.2
*/
- @SuppressWarnings("removal")
public void checkPermission(Permission perm, Object context) {
- if (context instanceof AccessControlContext) {
- ((AccessControlContext)context).checkPermission(perm);
- } else {
- throw new SecurityException();
- }
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to create a new class loader.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("createClassLoader")}
- * permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkCreateClassLoader}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @throws SecurityException if the calling thread does not
- * have permission
- * to create a new class loader.
- * @see java.lang.ClassLoader#ClassLoader()
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @throws SecurityException always
*/
public void checkCreateClassLoader() {
- checkPermission(SecurityConstants.CREATE_CLASSLOADER_PERMISSION);
- }
-
- /**
- * reference to the root thread group, used for the checkAccess
- * methods.
- */
-
- private static ThreadGroup rootGroup = getRootGroup();
-
- private static ThreadGroup getRootGroup() {
- ThreadGroup root = Thread.currentThread().getThreadGroup();
- while (root.getParent() != null) {
- root = root.getParent();
- }
- return root;
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to modify the thread argument.
- *
- * This method is invoked for the current security manager by the
- * {@code setPriority}, {@code setName}, and
- * {@code setDaemon} methods of class {@code Thread}.
- *
- * If the thread argument is a system thread (belongs to
- * the thread group with a {@code null} parent) then
- * this method calls {@code checkPermission} with the
- * {@code RuntimePermission("modifyThread")} permission.
- * If the thread argument is not a system thread,
- * this method just returns silently.
- *
- * Applications that want a stricter policy should override this
- * method. If this method is overridden, the method that overrides
- * it should additionally check to see if the calling thread has the
- * {@code RuntimePermission("modifyThread")} permission, and
- * if so, return silently. This is to ensure that code granted
- * that permission (such as the JDK itself) is allowed to
- * manipulate any thread.
- *
- * If this method is overridden, then
- * {@code super.checkAccess} should
- * be called by the first statement in the overridden method, or the
- * equivalent security check should be placed in the overridden method.
+ * Throws {@code SecurityException}.
*
- * @param t the thread to be checked.
- * @throws SecurityException if the calling thread does not have
- * permission to modify the thread.
- * @throws NullPointerException if the thread argument is
- * {@code null}.
- * @see java.lang.Thread#setDaemon(boolean) setDaemon
- * @see java.lang.Thread#setName(java.lang.String) setName
- * @see java.lang.Thread#setPriority(int) setPriority
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param t ignored
+ * @throws SecurityException always
*/
public void checkAccess(Thread t) {
- if (t == null) {
- throw new NullPointerException("thread can't be null");
- }
- if (t.getThreadGroup() == rootGroup) {
- checkPermission(SecurityConstants.MODIFY_THREAD_PERMISSION);
- } else {
- // just return
- }
+ throw new SecurityException();
}
+
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to modify the thread group argument.
- *
- * This method is invoked for the current security manager when a
- * new child thread or child thread group is created, and by the
- * {@code setDaemon} and {@code setMaxPriority} methods of class
- * {@code ThreadGroup}.
- *
- * If the thread group argument is the system thread group (
- * has a {@code null} parent) then
- * this method calls {@code checkPermission} with the
- * {@code RuntimePermission("modifyThreadGroup")} permission.
- * If the thread group argument is not the system thread group,
- * this method just returns silently.
- *
- * Applications that want a stricter policy should override this
- * method. If this method is overridden, the method that overrides
- * it should additionally check to see if the calling thread has the
- * {@code RuntimePermission("modifyThreadGroup")} permission, and
- * if so, return silently. This is to ensure that code granted
- * that permission (such as the JDK itself) is allowed to
- * manipulate any thread.
- *
- * If this method is overridden, then
- * {@code super.checkAccess} should
- * be called by the first statement in the overridden method, or the
- * equivalent security check should be placed in the overridden method.
+ * Throws {@code SecurityException}.
*
- * @param g the thread group to be checked.
- * @throws SecurityException if the calling thread does not have
- * permission to modify the thread group.
- * @throws NullPointerException if the thread group argument is
- * {@code null}.
- * @see java.lang.ThreadGroup#setDaemon(boolean) setDaemon
- * @see java.lang.ThreadGroup#setMaxPriority(int) setMaxPriority
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param g ignored
+ * @throws SecurityException always
*/
public void checkAccess(ThreadGroup g) {
- if (g == null) {
- throw new NullPointerException("thread group can't be null");
- }
- if (g == rootGroup) {
- checkPermission(SecurityConstants.MODIFY_THREADGROUP_PERMISSION);
- } else {
- // just return
- }
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to cause the Java Virtual Machine to
- * halt with the specified status code.
- *
- * This method is invoked for the current security manager by the
- * {@code exit} method of class {@code Runtime}. A status
- * of {@code 0} indicates success; other values indicate various
- * errors.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("exitVM."+status)} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkExit}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param status the exit status.
- * @throws SecurityException if the calling thread does not have
- * permission to halt the Java Virtual Machine with
- * the specified status.
- * @see java.lang.Runtime#exit(int) exit
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param status ignored
+ * @throws SecurityException always
*/
public void checkExit(int status) {
- checkPermission(new RuntimePermission("exitVM."+status));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to create a subprocess.
- *
- * This method is invoked for the current security manager by the
- * {@code exec} methods of class {@code Runtime}.
- *
- * This method calls {@code checkPermission} with the
- * {@code FilePermission(cmd,"execute")} permission
- * if cmd is an absolute path, otherwise it calls
- * {@code checkPermission} with
- *
- * If you override this method, then you should make a call to
- * {@code super.checkExec}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param cmd the specified system command.
- * @throws SecurityException if the calling thread does not have
- * permission to create a subprocess.
- * @throws NullPointerException if the {@code cmd} argument is
- * {@code null}.
- * @see java.lang.Runtime#exec(java.lang.String)
- * @see java.lang.Runtime#exec(java.lang.String, java.lang.String[])
- * @see java.lang.Runtime#exec(java.lang.String[])
- * @see java.lang.Runtime#exec(java.lang.String[], java.lang.String[])
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param cmd ignored
+ * @throws SecurityException always
*/
public void checkExec(String cmd) {
- File f = new File(cmd);
- if (f.isAbsolute()) {
- checkPermission(new FilePermission(cmd,
- SecurityConstants.FILE_EXECUTE_ACTION));
- } else {
- checkPermission(new FilePermission("<
- * This method is invoked for the current security manager by
- * methods {@code load} and {@code loadLibrary} of class
- * {@code Runtime}.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("loadLibrary."+lib)} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkLink}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param lib the name of the library.
- * @throws SecurityException if the calling thread does not have
- * permission to dynamically link the library.
- * @throws NullPointerException if the {@code lib} argument is
- * {@code null}.
- * @see java.lang.Runtime#load(java.lang.String)
- * @see java.lang.Runtime#loadLibrary(java.lang.String)
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param lib ignored
+ * @throws SecurityException always
*/
public void checkLink(String lib) {
- if (lib == null) {
- throw new NullPointerException("library can't be null");
- }
- checkPermission(new RuntimePermission("loadLibrary."+lib));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to read from the specified file
- * descriptor.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("readFileDescriptor")}
- * permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkRead}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param fd the system-dependent file descriptor.
- * @throws SecurityException if the calling thread does not have
- * permission to access the specified file descriptor.
- * @throws NullPointerException if the file descriptor argument is
- * {@code null}.
- * @see java.io.FileDescriptor
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param fd the system-dependent file descriptor
+ * @throws SecurityException always
*/
public void checkRead(FileDescriptor fd) {
- if (fd == null) {
- throw new NullPointerException("file descriptor can't be null");
- }
- checkPermission(new RuntimePermission("readFileDescriptor"));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to read the file specified by the
- * string argument.
- *
- * This method calls {@code checkPermission} with the
- * {@code FilePermission(file,"read")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkRead}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param file the system-dependent file name.
- * @throws SecurityException if the calling thread does not have
- * permission to access the specified file.
- * @throws NullPointerException if the {@code file} argument is
- * {@code null}.
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param file ignored
+ * @throws SecurityException always
*/
public void checkRead(String file) {
- checkPermission(new FilePermission(file,
- SecurityConstants.FILE_READ_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * specified security context is not allowed to read the file
- * specified by the string argument. The context must be a security
- * context returned by a previous call to
- * {@code getSecurityContext}.
- * If {@code context} is an instance of
- * {@code AccessControlContext} then the
- * {@code AccessControlContext.checkPermission} method will
- * be invoked with the {@code FilePermission(file,"read")} permission.
- * If {@code context} is not an instance of
- * {@code AccessControlContext} then a
- * {@code SecurityException} is thrown.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkRead}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param file the system-dependent filename.
- * @param context a system-dependent security context.
- * @throws SecurityException if the specified security context
- * is not an instance of {@code AccessControlContext}
- * (e.g., is {@code null}), or does not have permission
- * to read the specified file.
- * @throws NullPointerException if the {@code file} argument is
- * {@code null}.
- * @see java.lang.SecurityManager#getSecurityContext()
- * @see java.security.AccessControlContext#checkPermission(java.security.Permission)
+ * @param file ignored
+ * @param context ignored
+ * @throws SecurityException always
*/
public void checkRead(String file, Object context) {
- checkPermission(
- new FilePermission(file, SecurityConstants.FILE_READ_ACTION),
- context);
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to write to the specified file
- * descriptor.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("writeFileDescriptor")}
- * permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkWrite}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param fd the system-dependent file descriptor.
- * @throws SecurityException if the calling thread does not have
- * permission to access the specified file descriptor.
- * @throws NullPointerException if the file descriptor argument is
- * {@code null}.
- * @see java.io.FileDescriptor
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param fd ignored
+ * @throws SecurityException always
*/
public void checkWrite(FileDescriptor fd) {
- if (fd == null) {
- throw new NullPointerException("file descriptor can't be null");
- }
- checkPermission(new RuntimePermission("writeFileDescriptor"));
-
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to write to the file specified by
- * the string argument.
- *
- * This method calls {@code checkPermission} with the
- * {@code FilePermission(file,"write")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkWrite}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param file the system-dependent filename.
- * @throws SecurityException if the calling thread does not
- * have permission to access the specified file.
- * @throws NullPointerException if the {@code file} argument is
- * {@code null}.
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param file ignored
+ * @throws SecurityException always
*/
public void checkWrite(String file) {
- checkPermission(new FilePermission(file,
- SecurityConstants.FILE_WRITE_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to delete the specified file.
- *
- * This method is invoked for the current security manager by the
- * {@code delete} method of class {@code File}.
- *
- * This method calls {@code checkPermission} with the
- * {@code FilePermission(file,"delete")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkDelete}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param file the system-dependent filename.
- * @throws SecurityException if the calling thread does not
- * have permission to delete the file.
- * @throws NullPointerException if the {@code file} argument is
- * {@code null}.
- * @see java.io.File#delete()
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param file ignored
+ * @throws SecurityException always
*/
public void checkDelete(String file) {
- checkPermission(new FilePermission(file,
- SecurityConstants.FILE_DELETE_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to open a socket connection to the
- * specified host and port number.
- *
- * A port number of {@code -1} indicates that the calling
- * method is attempting to determine the IP address of the specified
- * host name.
- *
- * This method calls {@code checkPermission} with the
- * {@code SocketPermission(host+":"+port,"connect")} permission if
- * the port is not equal to -1. If the port is equal to -1, then
- * it calls {@code checkPermission} with the
- * {@code SocketPermission(host,"resolve")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkConnect}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param host the host name port to connect to.
- * @param port the protocol port to connect to.
- * @throws SecurityException if the calling thread does not have
- * permission to open a socket connection to the specified
- * {@code host} and {@code port}.
- * @throws NullPointerException if the {@code host} argument is
- * {@code null}.
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param host ignored
+ * @param port ignored
+ * @throws SecurityException always
*/
public void checkConnect(String host, int port) {
- if (host == null) {
- throw new NullPointerException("host can't be null");
- }
- if (!host.startsWith("[") && host.indexOf(':') != -1) {
- host = "[" + host + "]";
- }
- if (port == -1) {
- checkPermission(new SocketPermission(host,
- SecurityConstants.SOCKET_RESOLVE_ACTION));
- } else {
- checkPermission(new SocketPermission(host+":"+port,
- SecurityConstants.SOCKET_CONNECT_ACTION));
- }
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * specified security context is not allowed to open a socket
- * connection to the specified host and port number.
- *
- * A port number of {@code -1} indicates that the calling
- * method is attempting to determine the IP address of the specified
- * host name.
- * If {@code context} is not an instance of
- * {@code AccessControlContext} then a
- * {@code SecurityException} is thrown.
- *
- * Otherwise, the port number is checked. If it is not equal
- * to -1, the {@code context}'s {@code checkPermission}
- * method is called with a
- * {@code SocketPermission(host+":"+port,"connect")} permission.
- * If the port is equal to -1, then
- * the {@code context}'s {@code checkPermission} method
- * is called with a
- * {@code SocketPermission(host,"resolve")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkConnect}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param host the host name port to connect to.
- * @param port the protocol port to connect to.
- * @param context a system-dependent security context.
- * @throws SecurityException if the specified security context
- * is not an instance of {@code AccessControlContext}
- * (e.g., is {@code null}), or does not have permission
- * to open a socket connection to the specified
- * {@code host} and {@code port}.
- * @throws NullPointerException if the {@code host} argument is
- * {@code null}.
- * @see java.lang.SecurityManager#getSecurityContext()
- * @see java.security.AccessControlContext#checkPermission(java.security.Permission)
+ * @param host ignored
+ * @param port ignored
+ * @param context ignored
+ * @throws SecurityException always
*/
public void checkConnect(String host, int port, Object context) {
- if (host == null) {
- throw new NullPointerException("host can't be null");
- }
- if (!host.startsWith("[") && host.indexOf(':') != -1) {
- host = "[" + host + "]";
- }
- if (port == -1)
- checkPermission(new SocketPermission(host,
- SecurityConstants.SOCKET_RESOLVE_ACTION),
- context);
- else
- checkPermission(new SocketPermission(host+":"+port,
- SecurityConstants.SOCKET_CONNECT_ACTION),
- context);
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to wait for a connection request on
- * the specified local port number.
- *
- * This method calls {@code checkPermission} with the
- * {@code SocketPermission("localhost:"+port,"listen")}.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkListen}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param port the local port.
- * @throws SecurityException if the calling thread does not have
- * permission to listen on the specified port.
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param port ignored
+ * @throws SecurityException always
*/
public void checkListen(int port) {
- checkPermission(new SocketPermission("localhost:"+port,
- SecurityConstants.SOCKET_LISTEN_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not permitted to accept a socket connection from
- * the specified host and port number.
- *
- * This method is invoked for the current security manager by the
- * {@code accept} method of class {@code ServerSocket}.
- *
- * This method calls {@code checkPermission} with the
- * {@code SocketPermission(host+":"+port,"accept")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkAccept}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param host the host name of the socket connection.
- * @param port the port number of the socket connection.
- * @throws SecurityException if the calling thread does not have
- * permission to accept the connection.
- * @throws NullPointerException if the {@code host} argument is
- * {@code null}.
- * @see java.net.ServerSocket#accept()
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param host ignored
+ * @param port ignored
+ * @throws SecurityException always
*/
public void checkAccept(String host, int port) {
- if (host == null) {
- throw new NullPointerException("host can't be null");
- }
- if (!host.startsWith("[") && host.indexOf(':') != -1) {
- host = "[" + host + "]";
- }
- checkPermission(new SocketPermission(host+":"+port,
- SecurityConstants.SOCKET_ACCEPT_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to use
- * (join/leave/send/receive) IP multicast.
- *
- * This method calls {@code checkPermission} with the
- *
- * If you override this method, then you should make a call to
- * {@code super.checkMulticast}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param maddr Internet group address to be used.
- * @throws SecurityException if the calling thread is not allowed to
- * use (join/leave/send/receive) IP multicast.
- * @throws NullPointerException if the address argument is
- * {@code null}.
+ * @param maddr ignored
+ * @throws SecurityException always
* @since 1.1
- * @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkMulticast(InetAddress maddr) {
- String host = maddr.getHostAddress();
- if (!host.startsWith("[") && host.indexOf(':') != -1) {
- host = "[" + host + "]";
- }
- checkPermission(new SocketPermission(host,
- SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to use
- * (join/leave/send/receive) IP multicast.
- *
- * This method calls {@code checkPermission} with the
- *
- * If you override this method, then you should make a call to
- * {@code super.checkMulticast}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @param maddr Internet group address to be used.
- * @param ttl value in use, if it is multicast send.
- * Note: this particular implementation does not use the ttl
- * parameter.
- * @throws SecurityException if the calling thread is not allowed to
- * use (join/leave/send/receive) IP multicast.
- * @throws NullPointerException if the address argument is
- * {@code null}.
+ * @param maddr ignored
+ * @param ttl ignored
+ * @throws SecurityException always
* @since 1.1
- * @see #checkPermission(java.security.Permission) checkPermission
*/
- @Deprecated(since="1.4", forRemoval=true)
public void checkMulticast(InetAddress maddr, byte ttl) {
- String host = maddr.getHostAddress();
- if (!host.startsWith("[") && host.indexOf(':') != -1) {
- host = "[" + host + "]";
- }
- checkPermission(new SocketPermission(host,
- SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to access or modify the system
- * properties.
- *
- * This method is used by the {@code getProperties} and
- * {@code setProperties} methods of class {@code System}.
- *
- * This method calls {@code checkPermission} with the
- * {@code PropertyPermission("*", "read,write")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkPropertiesAccess}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @throws SecurityException if the calling thread does not have
- * permission to access or modify the system properties.
- * @see java.lang.System#getProperties()
- * @see java.lang.System#setProperties(java.util.Properties)
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @throws SecurityException always
*/
public void checkPropertiesAccess() {
- checkPermission(new PropertyPermission("*",
- SecurityConstants.PROPERTY_RW_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to access the system property with
- * the specified {@code key} name.
- *
- * This method is used by the {@code getProperty} method of
- * class {@code System}.
- *
- * This method calls {@code checkPermission} with the
- * {@code PropertyPermission(key, "read")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkPropertyAccess}
- * at the point the overridden method would normally throw an
- * exception.
- *
- * @param key a system property key.
+ * Throws {@code SecurityException}.
*
- * @throws SecurityException if the calling thread does not have
- * permission to access the specified system property.
- * @throws NullPointerException if the {@code key} argument is
- * {@code null}.
- * @throws IllegalArgumentException if {@code key} is empty.
- *
- * @see java.lang.System#getProperty(java.lang.String)
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @param key ignored
+ * @throws SecurityException always
*/
public void checkPropertyAccess(String key) {
- checkPermission(new PropertyPermission(key,
- SecurityConstants.PROPERTY_READ_ACTION));
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to initiate a print job request.
- *
- * This method calls
- * {@code checkPermission} with the
- * {@code RuntimePermission("queuePrintJob")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkPrintJobAccess}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @throws SecurityException if the calling thread does not have
- * permission to initiate a print job request.
+ * @throws SecurityException always
* @since 1.1
- * @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkPrintJobAccess() {
- checkPermission(new RuntimePermission("queuePrintJob"));
- }
-
- /*
- * We have an initial invalid bit (initially false) for the class
- * variables which tell if the cache is valid. If the underlying
- * java.security.Security property changes via setProperty(), the
- * Security class uses reflection to change the variable and thus
- * invalidate the cache.
- *
- * Locking is handled by synchronization to the
- * packageAccessLock/packageDefinitionLock objects. They are only
- * used in this class.
- *
- * Note that cache invalidation as a result of the property change
- * happens without using these locks, so there may be a delay between
- * when a thread updates the property and when other threads updates
- * the cache.
- */
- private static boolean packageAccessValid = false;
- private static String[] packageAccess;
- private static final Object packageAccessLock = new Object();
-
- private static boolean packageDefinitionValid = false;
- private static String[] packageDefinition;
- private static final Object packageDefinitionLock = new Object();
-
- private static String[] getPackages(String p) {
- String packages[] = null;
- if (p != null && !p.isEmpty()) {
- java.util.StringTokenizer tok =
- new java.util.StringTokenizer(p, ",");
- int n = tok.countTokens();
- if (n > 0) {
- packages = new String[n];
- int i = 0;
- while (tok.hasMoreElements()) {
- String s = tok.nextToken().trim();
- packages[i++] = s;
- }
- }
- }
-
- if (packages == null) {
- packages = new String[0];
- }
- return packages;
- }
-
- // The non-exported packages in modules defined to the boot or platform
- // class loaders. A non-exported package is a package that is not exported
- // or is only exported to specific modules.
- private static final Map
- * During class loading, this method may be called by the {@code loadClass}
- * method of class loaders and by the Java Virtual Machine to ensure that
- * the caller is allowed to access the package of the class that is
- * being loaded.
- *
- * This method checks if the specified package starts with or equals
- * any of the packages in the {@code package.access} Security Property.
- * An implementation may also check the package against an additional
- * list of restricted packages as noted below. If the package is restricted,
- * {@link #checkPermission(Permission)} is called with a
- * {@code RuntimePermission("accessClassInPackage."+pkg)} permission.
- *
- * If this method is overridden, then {@code super.checkPackageAccess}
- * should be called as the first line in the overridden method.
+ * Throws {@code SecurityException}.
*
- * @implNote
- * This implementation also restricts all non-exported packages of modules
- * loaded by {@linkplain ClassLoader#getPlatformClassLoader
- * the platform class loader} or its ancestors. A "non-exported package"
- * refers to a package that is not exported to all modules. Specifically,
- * it refers to a package that either is not exported at all by its
- * containing module or is exported in a qualified fashion by its
- * containing module.
- *
- * @param pkg the package name.
- * @throws SecurityException if the calling thread does not have
- * permission to access the specified package.
- * @throws NullPointerException if the package name argument is
- * {@code null}.
- * @see java.lang.ClassLoader#loadClass(String, boolean) loadClass
- * @see java.security.Security#getProperty getProperty
- * @see #checkPermission(Permission) checkPermission
+ * @param pkg ignored
+ * @throws SecurityException always
*/
public void checkPackageAccess(String pkg) {
- Objects.requireNonNull(pkg, "package name can't be null");
-
- // check if pkg is not exported to all modules
- if (nonExportedPkgs.containsKey(pkg)) {
- checkPermission(
- new RuntimePermission("accessClassInPackage." + pkg));
- return;
- }
-
- String[] restrictedPkgs;
- synchronized (packageAccessLock) {
- /*
- * Do we need to update our property array?
- */
- if (!packageAccessValid) {
- @SuppressWarnings("removal")
- String tmpPropertyStr =
- AccessController.doPrivileged(
- new PrivilegedAction<>() {
- public String run() {
- return Security.getProperty("package.access");
- }
- }
- );
- packageAccess = getPackages(tmpPropertyStr);
- packageAccessValid = true;
- }
-
- // Using a snapshot of packageAccess -- don't care if static field
- // changes afterwards; array contents won't change.
- restrictedPkgs = packageAccess;
- }
-
- /*
- * Traverse the list of packages, check for any matches.
- */
- final int plen = pkg.length();
- for (String restrictedPkg : restrictedPkgs) {
- final int rlast = restrictedPkg.length() - 1;
-
- // Optimizations:
- //
- // If rlast >= plen then restrictedPkg is longer than pkg by at
- // least one char. This means pkg cannot start with restrictedPkg,
- // since restrictedPkg will be longer than pkg.
- //
- // Similarly if rlast != plen, then pkg + "." cannot be the same
- // as restrictedPkg, since pkg + "." will have a different length
- // than restrictedPkg.
- //
- if (rlast < plen && pkg.startsWith(restrictedPkg) ||
- // The following test is equivalent to
- // restrictedPkg.equals(pkg + ".") but is noticeably more
- // efficient:
- rlast == plen && restrictedPkg.startsWith(pkg) &&
- restrictedPkg.charAt(rlast) == '.')
- {
- checkPermission(
- new RuntimePermission("accessClassInPackage." + pkg));
- break; // No need to continue; only need to check this once
- }
- }
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the calling thread is not
- * allowed to define classes in the specified package.
- *
- * This method is called by the {@code loadClass} method of some
- * class loaders.
- *
- * This method checks if the specified package starts with or equals
- * any of the packages in the {@code package.definition} Security
- * Property. An implementation may also check the package against an
- * additional list of restricted packages as noted below. If the package
- * is restricted, {@link #checkPermission(Permission)} is called with a
- * {@code RuntimePermission("defineClassInPackage."+pkg)} permission.
- *
- * If this method is overridden, then {@code super.checkPackageDefinition}
- * should be called as the first line in the overridden method.
+ * Throws {@code SecurityException}.
*
- * @implNote
- * This implementation also restricts all non-exported packages of modules
- * loaded by {@linkplain ClassLoader#getPlatformClassLoader
- * the platform class loader} or its ancestors. A "non-exported package"
- * refers to a package that is not exported to all modules. Specifically,
- * it refers to a package that either is not exported at all by its
- * containing module or is exported in a qualified fashion by its
- * containing module.
- *
- * @param pkg the package name.
- * @throws SecurityException if the calling thread does not have
- * permission to define classes in the specified package.
- * @throws NullPointerException if the package name argument is
- * {@code null}.
- * @see java.lang.ClassLoader#loadClass(String, boolean)
- * @see java.security.Security#getProperty getProperty
- * @see #checkPermission(Permission) checkPermission
+ * @param pkg ignored
+ * @throws SecurityException always
*/
public void checkPackageDefinition(String pkg) {
- Objects.requireNonNull(pkg, "package name can't be null");
-
- // check if pkg is not exported to all modules
- if (nonExportedPkgs.containsKey(pkg)) {
- checkPermission(
- new RuntimePermission("defineClassInPackage." + pkg));
- return;
- }
-
- String[] pkgs;
- synchronized (packageDefinitionLock) {
- /*
- * Do we need to update our property array?
- */
- if (!packageDefinitionValid) {
- @SuppressWarnings("removal")
- String tmpPropertyStr =
- AccessController.doPrivileged(
- new PrivilegedAction<>() {
- public String run() {
- return java.security.Security.getProperty(
- "package.definition");
- }
- }
- );
- packageDefinition = getPackages(tmpPropertyStr);
- packageDefinitionValid = true;
- }
- // Using a snapshot of packageDefinition -- don't care if static
- // field changes afterwards; array contents won't change.
- pkgs = packageDefinition;
- }
-
- /*
- * Traverse the list of packages, check for any matches.
- */
- for (String restrictedPkg : pkgs) {
- if (pkg.startsWith(restrictedPkg) || restrictedPkg.equals(pkg + ".")) {
- checkPermission(
- new RuntimePermission("defineClassInPackage." + pkg));
- break; // No need to continue; only need to check this once
- }
- }
+ throw new SecurityException();
}
/**
- * Throws a {@code SecurityException} if the
- * calling thread is not allowed to set the socket factory used by
- * {@code ServerSocket} or {@code Socket}, or the stream
- * handler factory used by {@code URL}.
- *
- * This method calls {@code checkPermission} with the
- * {@code RuntimePermission("setFactory")} permission.
- *
- * If you override this method, then you should make a call to
- * {@code super.checkSetFactory}
- * at the point the overridden method would normally throw an
- * exception.
+ * Throws {@code SecurityException}.
*
- * @throws SecurityException if the calling thread does not have
- * permission to specify a socket factory or a stream
- * handler factory.
- *
- * @see java.net.ServerSocket#setSocketFactory(java.net.SocketImplFactory) setSocketFactory
- * @see java.net.Socket#setSocketImplFactory(java.net.SocketImplFactory) setSocketImplFactory
- * @see java.net.URL#setURLStreamHandlerFactory(java.net.URLStreamHandlerFactory) setURLStreamHandlerFactory
- * @see #checkPermission(java.security.Permission) checkPermission
+ * @throws SecurityException always
*/
public void checkSetFactory() {
- checkPermission(new RuntimePermission("setFactory"));
+ throw new SecurityException();
}
/**
- * Determines whether the permission with the specified permission target
- * name should be granted or denied.
- *
- * If the requested permission is allowed, this method returns
- * quietly. If denied, a SecurityException is raised.
- *
- * This method creates a {@code SecurityPermission} object for
- * the given permission target name and calls {@code checkPermission}
- * with it.
- *
- * See the documentation for
- * If you override this method, then you should make a call to
- * {@code super.checkSecurityAccess}
- * at the point the overridden method would normally throw an
- * exception.
- *
- * @param target the target name of the {@code SecurityPermission}.
- *
- * @throws SecurityException if the calling thread does not have
- * permission for the requested access.
- * @throws NullPointerException if {@code target} is null.
- * @throws IllegalArgumentException if {@code target} is empty.
+ * Throws {@code SecurityException}.
*
+ * @param target ignored
+ * @throws SecurityException always
* @since 1.1
- * @see #checkPermission(java.security.Permission) checkPermission
*/
public void checkSecurityAccess(String target) {
- checkPermission(new SecurityPermission(target));
+ throw new SecurityException();
}
/**
- * Returns the thread group into which to instantiate any new
- * thread being created at the time this is being called.
- * By default, it returns the thread group of the current
- * thread. This should be overridden by a specific security
- * manager to return the appropriate thread group.
- *
- * @return ThreadGroup that new threads are instantiated into
+ * {@return the current Thread's {@code ThreadGroup}}
* @since 1.1
- * @see java.lang.ThreadGroup
*/
public ThreadGroup getThreadGroup() {
return Thread.currentThread().getThreadGroup();
}
-
}
diff --git a/src/java.base/share/classes/java/lang/StackWalker.java b/src/java.base/share/classes/java/lang/StackWalker.java
index 8a39c465c2bca..a6756f3278be6 100644
--- a/src/java.base/share/classes/java/lang/StackWalker.java
+++ b/src/java.base/share/classes/java/lang/StackWalker.java
@@ -61,9 +61,6 @@
*
* {@code StackWalker} is thread-safe. Multiple threads can share
* a single {@code StackWalker} object to traverse its own stack.
- * A permission check is performed when a {@code StackWalker} is created,
- * according to the options it requests.
- * No further permission check is done at stack walking time.
*
* @apiNote
* Examples
@@ -354,18 +351,10 @@ public static StackWalker getInstance() {
/**
* Returns a {@code StackWalker} instance with the given option specifying
* the stack frame information it can access.
- *
- * If a security manager is present and the given {@code option} is
- * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
- * it calls its {@link SecurityManager#checkPermission checkPermission}
- * method for {@code RuntimePermission("getStackWalkerWithClassReference")}.
*
* @param option {@link Option stack walking option}
*
* @return a {@code StackWalker} configured with the given option
- *
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies access.
*/
public static StackWalker getInstance(Option option) {
return getInstance(EnumSet.of(Objects.requireNonNull(option)));
@@ -380,18 +369,9 @@ public static StackWalker getInstance(Option option) {
* configured to skip all {@linkplain Option#SHOW_HIDDEN_FRAMES hidden frames}
* and no {@linkplain Option#RETAIN_CLASS_REFERENCE class reference} is retained.
*
- *
- * If a security manager is present and the given {@code options} contains
- * {@link Option#RETAIN_CLASS_REFERENCE Option.RETAIN_CLASS_REFERENCE},
- * it calls its {@link SecurityManager#checkPermission checkPermission}
- * method for {@code RuntimePermission("getStackWalkerWithClassReference")}.
- *
* @param options {@link Option stack walking options}
*
* @return a {@code StackWalker} configured with the given options
- *
- * @throws SecurityException if a security manager exists and its
- * {@code checkPermission} method denies access.
*/
public static StackWalker getInstance(Set
@@ -647,11 +595,6 @@ public Process exec(String[] cmdarray, String[] envp) throws IOException {
*
* @return A new {@link Process} object for managing the subprocess
*
- * @throws SecurityException
- * If a security manager exists and its
- * {@link SecurityManager#checkExec checkExec}
- * method doesn't allow creation of the subprocess
- *
* @throws UnsupportedOperationException
* If the operating system does not support the creation of processes.
*
@@ -808,10 +751,6 @@ public void runFinalization() {
* Otherwise, the filename argument is mapped to a native library image in
* an implementation-dependent manner.
*
- *
- *
- *
- *
- * @implNote
- * Implementations may define additional target names, but should use naming
- * conventions such as reverse domain name notation to avoid name clashes.
+ * @apiNote
+ * This permission cannot be used for controlling access to resources anymore
+ * as the Security Manager is no longer supported.
*
* @see java.security.BasicPermission
* @see java.security.Permission
@@ -388,7 +48,6 @@
* @see java.security.PermissionCollection
* @see java.lang.SecurityManager
*
- *
* @author Marianne Mueller
* @author Roland Schemers
* @since 1.2
diff --git a/src/java.base/share/classes/java/lang/SecurityException.java b/src/java.base/share/classes/java/lang/SecurityException.java
index 4e4f966f76a36..a7fb830ac75ea 100644
--- a/src/java.base/share/classes/java/lang/SecurityException.java
+++ b/src/java.base/share/classes/java/lang/SecurityException.java
@@ -25,9 +25,12 @@
package java.lang;
/**
- * Thrown by the security manager to indicate a security violation.
+ * Thrown to indicate a security violation.
+ *
+ *
- *
- *
- *
- *
- * Permission Target Name
- * What the Permission Allows
- * Risks of Allowing this Permission
- *
- *
- *
- * createClassLoader
- * Creation of a class loader
- * This is an extremely dangerous permission to grant.
- * Malicious applications that can instantiate their own class
- * loaders could then load their own rogue classes into the system.
- * These newly loaded classes could be placed into any protection
- * domain by the class loader, thereby automatically granting the
- * classes the permissions for that domain.
- *
- *
- *
- * getClassLoader
- * Retrieval of a class loader (e.g., the class loader for the calling
- * class)
- * This would grant an attacker permission to get the
- * class loader for a particular class. This is dangerous because
- * having access to a class's class loader allows the attacker to
- * load other classes available to that class loader. The attacker
- * would typically otherwise not have access to those classes.
- *
- *
- *
- * setContextClassLoader
- * Setting of the context class loader used by a thread
- * The context class loader is used by system code and extensions
- * when they need to lookup resources that might not exist in the system
- * class loader. Granting setContextClassLoader permission would allow
- * code to change which context class loader is used
- * for a particular thread, including system threads.
- *
- *
- *
- * enableContextClassLoaderOverride
- * Subclass implementation of the thread context class loader methods
- * The context class loader is used by system code and extensions
- * when they need to lookup resources that might not exist in the system
- * class loader. Granting enableContextClassLoaderOverride permission would allow
- * a subclass of Thread to override the methods that are used
- * to get or set the context class loader for a particular thread.
- *
- *
- *
- * closeClassLoader
- * Closing of a ClassLoader
- * Granting this permission allows code to close any URLClassLoader
- * that it has a reference to.
- *
- *
- *
- * setSecurityManager
- * Setting of the security manager (possibly replacing an existing one)
- *
- * The security manager is a class that allows
- * applications to implement a security policy. Granting the setSecurityManager
- * permission would allow code to change which security manager is used by
- * installing a different, possibly less restrictive security manager,
- * thereby bypassing checks that would have been enforced by the original
- * security manager.
- *
- *
- *
- * createSecurityManager
- * Creation of a new security manager
- * This gives code access to protected, sensitive methods that may
- * disclose information about other classes or the execution stack.
- *
- *
- *
- * getenv.{variable name}
- * Reading of the value of the specified environment variable
- * This would allow code to read the value, or determine the
- * existence, of a particular environment variable. This is
- * dangerous if the variable contains confidential data.
- *
- *
- *
- * exitVM.{exit status}
- * Halting of the Java Virtual Machine with the specified exit status
- * This allows an attacker to mount a denial-of-service attack
- * by automatically forcing the virtual machine to halt.
- * Note: The "exitVM.*" permission is automatically granted to all code
- * loaded from the application class path, thus enabling applications
- * to terminate themselves. Also, the "exitVM" permission is equivalent to
- * "exitVM.*".
- *
- *
- *
- * shutdownHooks
- * Registration and cancellation of virtual-machine shutdown hooks
- * This allows an attacker to register a malicious shutdown
- * hook that interferes with the clean shutdown of the virtual machine.
- *
- *
- *
- * setFactory
- * Setting of the socket factory used by ServerSocket or Socket,
- * or of the stream handler factory used by URL
- * This allows code to set the actual implementation
- * for the socket, server socket, stream handler, or RMI socket factory.
- * An attacker may set a faulty implementation which mangles the data
- * stream.
- *
- *
- *
- * setIO
- * Setting of System.out, System.in, and System.err
- * This allows changing the value of the standard system streams.
- * An attacker may change System.in to monitor and
- * steal user input, or may set System.err to a "null" OutputStream,
- * which would hide any error messages sent to System.err.
- *
- *
- *
- * modifyThread
- * Modification of threads, e.g., via calls to Thread
- * {@code interrupt, setDaemon, setPriority, setName} and
- * {@code setUncaughtExceptionHandler} methods
- * This allows an attacker to modify the behaviour of
- * any thread in the system.
- *
- *
- *
- * modifyThreadGroup
- * modification of thread groups, e.g., via calls to ThreadGroup
- * {@code getParent}, {@code setDaemon}, and {@code setMaxPriority} methods
- * This allows an attacker to create thread groups and
- * set their run priority.
- *
- *
- *
- * getProtectionDomain
- * Retrieval of the ProtectionDomain for a class
- * This allows code to obtain policy information
- * for a particular code source. While obtaining policy information
- * does not compromise the security of the system, it does give
- * attackers additional information, such as local file names for
- * example, to better aim an attack.
- *
- *
- *
- * getFileSystemAttributes
- * Retrieval of file system attributes
- * This allows code to obtain file system information such as disk usage
- * or disk space available to the caller. This is potentially dangerous
- * because it discloses information about the system hardware
- * configuration and some information about the caller's privilege to
- * write files.
- *
- *
- *
- * readFileDescriptor
- * Reading of file descriptors
- * This would allow code to read the particular file associated
- * with the file descriptor read. This is dangerous if the file
- * contains confidential data.
- *
- *
- *
- * writeFileDescriptor
- * Writing to file descriptors
- * This allows code to write to a particular file associated
- * with the descriptor. This is dangerous because it may allow
- * malicious code to plant viruses or at the very least, fill up
- * your entire disk.
- *
- *
- *
- * loadLibrary.{library name}
- * Dynamic linking of the specified library
- * It is dangerous to allow an applet permission to load native code
- * libraries, because the Java security architecture is not designed to and
- * does not prevent malicious behavior at the level of native code.
- *
- *
- *
- * accessClassInPackage.{package name}
- * Access to the specified package via a class loader's
- * {@code loadClass} method when that class loader calls
- * the SecurityManager {@code checkPackageAccess} method
- * This gives code access to classes in packages
- * to which it normally does not have access. Malicious code
- * may use these classes to help in its attempt to compromise
- * security in the system.
- *
- *
- *
- * defineClassInPackage.{package name}
- * Definition of classes in the specified package, via a class
- * loader's {@code defineClass} method when that class loader calls
- * the SecurityManager {@code checkPackageDefinition} method.
- * This grants code permission to define a class
- * in a particular package. This is dangerous because malicious
- * code with this permission may define rogue classes in
- * trusted packages like {@code java.security} or {@code java.lang},
- * for example.
- *
- *
- *
- * defineClass
- * Define a class with
- * {@link java.lang.invoke.MethodHandles.Lookup#defineClass(byte[])
- * Lookup.defineClass}.
- * This grants code with a suitably privileged {@code Lookup} object
- * permission to define classes in the same package as the {@code Lookup}'s
- * lookup class.
- *
- *
- * accessDeclaredMembers
- * Access to the declared members of a class
- * This grants code permission to query a class for its public,
- * protected, default (package) access, and private fields and/or
- * methods. Although the code would have
- * access to the private and protected field and method names, it would not
- * have access to the private/protected field data and would not be able
- * to invoke any private methods. Nevertheless, malicious code
- * may use this information to better aim an attack.
- * Additionally, it may invoke any public methods and/or access public fields
- * in the class. This could be dangerous if
- * the code would normally not be able to invoke those methods and/or
- * access the fields because
- * it can't cast the object to the class/interface with those methods
- * and fields.
- *
- *
- *
- * queuePrintJob
- * Initiation of a print job request
- * This could print sensitive information to a printer,
- * or simply waste paper.
- *
- *
- *
- * getStackTrace
- * Retrieval of the stack trace information of another thread.
- * This allows retrieval of the stack trace information of
- * another thread. This might allow malicious code to monitor the
- * execution of threads and discover vulnerabilities in applications.
- *
- *
- *
- * getStackWalkerWithClassReference
- * Get a stack walker that can retrieve stack frames with class reference.
- * This allows retrieval of Class objects from stack walking.
- * This might allow malicious code to access Class objects on the stack
- * outside its own context.
- *
- *
- *
- * setDefaultUncaughtExceptionHandler
- * Setting the default handler to be used when a thread
- * terminates abruptly due to an uncaught exception
- * This allows an attacker to register a malicious
- * uncaught exception handler that could interfere with termination
- * of a thread
- *
- *
- *
- * preferences
- * Represents the permission required to get access to the
- * java.util.prefs.Preferences implementations user or system root
- * which in turn allows retrieval or update operations within the
- * Preferences persistent backing store.)
- * This permission allows the user to read from or write to the
- * preferences backing store if the user running the code has
- * sufficient OS privileges to read/write to that backing store.
- * The actual backing store may reside within a traditional filesystem
- * directory or within a registry depending on the platform OS
- *
- *
- *
- * manageProcess
- * Native process termination and information about processes
- * {@link ProcessHandle}.
- * Allows code to identify and terminate processes that it did not create.
- *
- *
- *
- * localeServiceProvider
- * This {@code RuntimePermission} is required to be granted to
- * classes which subclass and implement
- * {@code java.util.spi.LocaleServiceProvider}. The permission is
- * checked during invocation of the abstract base class constructor.
- * This permission ensures trust in classes which implement this
- * security-sensitive provider mechanism.
- * See
- * {@code java.util.spi.LocaleServiceProvider} for more
- * information.
- *
- *
- *
- * loggerFinder
- * This {@code RuntimePermission} is required to be granted to
- * classes which subclass or call methods on
- * {@code java.lang.System.LoggerFinder}. The permission is
- * checked during invocation of the abstract base class constructor, as
- * well as on the invocation of its public methods.
- * This permission ensures trust in classes which provide loggers
- * to system classes.
- * See {@link java.lang.System.LoggerFinder java.lang.System.LoggerFinder}
- * for more information.
- *
- *
- *
- * accessSystemModules
- * Access system modules in the runtime image.
- * This grants the permission to access resources in the
- * {@linkplain ModuleFinder#ofSystem system modules} in the runtime image.
- *
- *
- *
- *
- * inetAddressResolverProvider
- * This {@code RuntimePermission} is required to be granted to
- * classes which subclass and implement {@code java.net.spi.InetAddressResolverProvider}.
- * The permission is checked during invocation of the abstract base class constructor.
- * This permission ensures trust in classes which provide resolvers used by
- * {@link java.net.InetAddress} hostname and address resolution methods.
- * See {@link java.net.spi.InetAddressResolverProvider} for more information.
- *
- *
- * SecurityManager security = System.getSecurityManager();
- * if (security != null) {
- * security.checkXXX(argument, . . . );
- * }
- * Setting a Security Manager
- * 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 {@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
- * a public no-arg constructor. The class is loaded by the
- * {@linkplain ClassLoader#getSystemClassLoader() built-in system class loader}
- * if it is not {@code java.lang.SecurityManager}. If the
- * {@code java.security.manager} system property is not set, the default value
- * is {@code null}, which means a security manager will not be set at startup.
- *
- *
- *
- *
- *
- *
- *
- *
- *
- * Property Value
- * The SecurityManager set at startup
- * System.setSecurityManager run-time behavior
- *
- *
- *
- * null
- * None
- * Throws {@code UnsupportedOperationException}
- *
- *
- *
- * empty String ("")
- * {@code java.lang.SecurityManager}
- * Success or throws {@code SecurityException} if not permitted by
- * the currently installed security manager
- *
- *
- *
- * "default"
- * {@code java.lang.SecurityManager}
- * Success or throws {@code SecurityException} if not permitted by
- * the currently installed security manager
- *
- *
- *
- * "disallow"
- * None
- * Throws {@code UnsupportedOperationException}
- *
- *
- *
- * "allow"
- * None
- * Success or throws {@code SecurityException} if not permitted by
- * the currently installed security manager
- *
- *
- *
- *
- * a class name
- * the named class
- * Success or throws {@code SecurityException} if not permitted by
- * the currently installed security manager
- * Checking Permissions
- * The special method
- * {@link SecurityManager#checkPermission(java.security.Permission)}
- * determines whether an access request indicated by a specified
- * permission should be granted or denied. The
- * default implementation calls
- *
- *
- * AccessController.checkPermission(perm);
- *
- *
- *
- * Object context = null;
- * SecurityManager sm = System.getSecurityManager();
- * if (sm != null) context = sm.getSecurityContext();
- *
- *
- *
- * if (sm != null) sm.checkPermission(permission, context);
- *
- *
- * FilePermission("<<ALL FILES>>","execute").
- * java.net.SocketPermission(maddr.getHostAddress(),
- * "accept,connect") permission.
- * java.net.SocketPermission(maddr.getHostAddress(),
- * "accept,connect") permission.
- * {@link java.security.SecurityPermission} for
- * a list of possible permission target names.
- *
- *