diff --git a/src/share/classes/java/util/logging/FileHandler.java b/src/share/classes/java/util/logging/FileHandler.java
index fb3b67c4d923e53ad661b1b905881810a903e799..b9a5d73c34150924c22bfe0bdab8b99fa0b4f3f1 100644
--- a/src/share/classes/java/util/logging/FileHandler.java
+++ b/src/share/classes/java/util/logging/FileHandler.java
@@ -220,7 +220,7 @@ public class FileHandler extends StreamHandler {
* @exception NullPointerException if pattern property is an empty String.
*/
public FileHandler() throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
configure();
openFiles();
}
@@ -246,7 +246,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
@@ -278,7 +278,7 @@ public class FileHandler extends StreamHandler {
if (pattern.length() < 1 ) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = 0;
@@ -315,7 +315,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
@@ -354,7 +354,7 @@ public class FileHandler extends StreamHandler {
if (limit < 0 || count < 1 || pattern.length() < 1) {
throw new IllegalArgumentException();
}
- checkAccess();
+ checkPermission();
configure();
this.pattern = pattern;
this.limit = limit;
@@ -367,7 +367,7 @@ public class FileHandler extends StreamHandler {
// configured instance variables.
private void openFiles() throws IOException {
LogManager manager = LogManager.getLogManager();
- manager.checkAccess();
+ manager.checkPermission();
if (count < 1) {
throw new IllegalArgumentException("file count = " + count);
}
diff --git a/src/share/classes/java/util/logging/Handler.java b/src/share/classes/java/util/logging/Handler.java
index 1317b572d929c02cf9f4713c1fa9b24e7fb784fa..fd04c2cb49691bd1f472accb3af0a484a47c5db8 100644
--- a/src/share/classes/java/util/logging/Handler.java
+++ b/src/share/classes/java/util/logging/Handler.java
@@ -111,7 +111,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setFormatter(Formatter newFormatter) throws SecurityException {
- checkAccess();
+ checkPermission();
// Check for a null pointer:
newFormatter.getClass();
formatter = newFormatter;
@@ -140,7 +140,7 @@ public abstract class Handler {
*/
public void setEncoding(String encoding)
throws SecurityException, java.io.UnsupportedEncodingException {
- checkAccess();
+ checkPermission();
if (encoding != null) {
try {
if(!java.nio.charset.Charset.isSupported(encoding)) {
@@ -175,7 +175,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setFilter(Filter newFilter) throws SecurityException {
- checkAccess();
+ checkPermission();
filter = newFilter;
}
@@ -199,7 +199,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public void setErrorManager(ErrorManager em) {
- checkAccess();
+ checkPermission();
if (em == null) {
throw new NullPointerException();
}
@@ -213,7 +213,7 @@ public abstract class Handler {
* the caller does not have LoggingPermission("control").
*/
public ErrorManager getErrorManager() {
- checkAccess();
+ checkPermission();
return errorManager;
}
@@ -253,7 +253,7 @@ public abstract class Handler {
if (newLevel == null) {
throw new NullPointerException();
}
- checkAccess();
+ checkPermission();
logLevel = newLevel;
}
@@ -296,9 +296,9 @@ public abstract class Handler {
// If "sealed" is true, we check that the caller has
// appropriate security privileges to update Handler
// state and if not throw a SecurityException.
- void checkAccess() throws SecurityException {
+ void checkPermission() throws SecurityException {
if (sealed) {
- manager.checkAccess();
+ manager.checkPermission();
}
}
}
diff --git a/src/share/classes/java/util/logging/LogManager.java b/src/share/classes/java/util/logging/LogManager.java
index 24f61b46f74b404e19ba3fb5aa7d7abf115036bc..bfdf83f93dab97a00732ff4890e6047b3fe4abd1 100644
--- a/src/share/classes/java/util/logging/LogManager.java
+++ b/src/share/classes/java/util/logging/LogManager.java
@@ -314,7 +314,7 @@ public class LogManager {
*/
public void addPropertyChangeListener(PropertyChangeListener l) throws SecurityException {
PropertyChangeListener listener = Objects.requireNonNull(l);
- checkAccess();
+ checkPermission();
synchronized (listenerMap) {
// increment the registration count if already registered
Integer value = listenerMap.get(listener);
@@ -338,7 +338,7 @@ public class LogManager {
* the caller does not have LoggingPermission("control").
*/
public void removePropertyChangeListener(PropertyChangeListener l) throws SecurityException {
- checkAccess();
+ checkPermission();
if (l != null) {
PropertyChangeListener listener = l;
synchronized (listenerMap) {
@@ -793,7 +793,7 @@ public class LogManager {
* @exception IOException if there are IO problems reading the configuration.
*/
public void readConfiguration() throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
// if a configuration class is specified, load it and use it.
String cname = System.getProperty("java.util.logging.config.class");
@@ -851,7 +851,7 @@ public class LogManager {
*/
public void reset() throws SecurityException {
- checkAccess();
+ checkPermission();
synchronized (this) {
props = new Properties();
// Since we are doing a reset we no longer want to initialize
@@ -936,7 +936,7 @@ public class LogManager {
* @exception IOException if there are problems reading from the stream.
*/
public void readConfiguration(InputStream ins) throws IOException, SecurityException {
- checkAccess();
+ checkPermission();
reset();
// Load the properties
@@ -1113,8 +1113,13 @@ public class LogManager {
loadLoggerHandlers(rootLogger, null, "handlers");
}
+ private final Permission controlPermission = new LoggingPermission("control", null);
- private Permission ourPermission = new LoggingPermission("control", null);
+ void checkPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null)
+ sm.checkPermission(controlPermission);
+ }
/**
* Check that the current context is trusted to modify the logging
@@ -1127,11 +1132,7 @@ public class LogManager {
* the caller does not have LoggingPermission("control").
*/
public void checkAccess() throws SecurityException {
- SecurityManager sm = System.getSecurityManager();
- if (sm == null) {
- return;
- }
- sm.checkPermission(ourPermission);
+ checkPermission();
}
// Nested class to represent a node in our tree of named loggers.
diff --git a/src/share/classes/java/util/logging/Logger.java b/src/share/classes/java/util/logging/Logger.java
index aebf63ed5e8c34b0e296cb2e2a62988353d6a14d..f1d6f729b91587106003fae01851d414e6eba549 100644
--- a/src/share/classes/java/util/logging/Logger.java
+++ b/src/share/classes/java/util/logging/Logger.java
@@ -276,13 +276,13 @@ public class Logger {
this.manager = manager;
}
- private void checkAccess() throws SecurityException {
+ private void checkPermission() throws SecurityException {
if (!anonymous) {
if (manager == null) {
// Complete initialization of the global Logger.
manager = LogManager.getLogManager();
}
- manager.checkAccess();
+ manager.checkPermission();
}
}
@@ -482,7 +482,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setFilter(Filter newFilter) throws SecurityException {
- checkAccess();
+ checkPermission();
filter = newFilter;
}
@@ -1168,7 +1168,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setLevel(Level newLevel) throws SecurityException {
- checkAccess();
+ checkPermission();
synchronized (treeLock) {
levelObject = newLevel;
updateEffectiveLevel();
@@ -1223,7 +1223,7 @@ public class Logger {
public void addHandler(Handler handler) throws SecurityException {
// Check for null handler
handler.getClass();
- checkAccess();
+ checkPermission();
handlers.add(handler);
}
@@ -1237,7 +1237,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void removeHandler(Handler handler) throws SecurityException {
- checkAccess();
+ checkPermission();
if (handler == null) {
return;
}
@@ -1265,7 +1265,7 @@ public class Logger {
* the caller does not have LoggingPermission("control").
*/
public void setUseParentHandlers(boolean useParentHandlers) {
- checkAccess();
+ checkPermission();
this.useParentHandlers = useParentHandlers;
}
@@ -1420,7 +1420,7 @@ public class Logger {
if (parent == null) {
throw new NullPointerException();
}
- manager.checkAccess();
+ manager.checkPermission();
doSetParent(parent);
}
diff --git a/src/share/classes/java/util/logging/MemoryHandler.java b/src/share/classes/java/util/logging/MemoryHandler.java
index 2c297301d924dcc0460fd353d5ef066794ae5538..06c0930ed5c22c97bcc175e07d71603f368283ff 100644
--- a/src/share/classes/java/util/logging/MemoryHandler.java
+++ b/src/share/classes/java/util/logging/MemoryHandler.java
@@ -238,7 +238,7 @@ public class MemoryHandler extends Handler {
throw new NullPointerException();
}
LogManager manager = LogManager.getLogManager();
- checkAccess();
+ checkPermission();
pushLevel = newLevel;
}
diff --git a/src/share/classes/java/util/logging/StreamHandler.java b/src/share/classes/java/util/logging/StreamHandler.java
index 9ed9e57b7686ae71cf2b2f5350613f65bd65e732..f6407ec2bfd176c6d19fca9c7567d942a5e2a01a 100644
--- a/src/share/classes/java/util/logging/StreamHandler.java
+++ b/src/share/classes/java/util/logging/StreamHandler.java
@@ -249,7 +249,7 @@ public class StreamHandler extends Handler {
}
private synchronized void flushAndClose() throws SecurityException {
- checkAccess();
+ checkPermission();
if (writer != null) {
try {
if (!doneHeader) {