8266459: Implement JEP 411: Deprecate the Security Manager for Removal

Co-authored-by: Sean Mullan <mullan@openjdk.org>
Co-authored-by: Lance Andersen <lancea@openjdk.org>
Co-authored-by: Weijun Wang <weijun@openjdk.org>
Reviewed-by: erikj, darcy, chegar, naoto, joehw, alanb, mchung, kcr, prr, lancea
This commit is contained in:
Weijun Wang 2021-06-02 11:57:31 +00:00
parent 19450b9951
commit 6765f90250
826 changed files with 2734 additions and 757 deletions

View file

@ -760,6 +760,7 @@ public class FileHandler extends StreamHandler {
* @param record description of the log event. A null record is
* silently ignored and is not published
*/
@SuppressWarnings("removal")
@Override
public synchronized void publish(LogRecord record) {
if (!isLoggable(record)) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -87,6 +87,7 @@ public abstract class Handler {
* nor found in LogManager configuration properties
* @param specifiedFormatter if not null, this is the formatter to configure
*/
@SuppressWarnings("removal")
Handler(Level defaultLevel, Formatter defaultFormatter,
Formatter specifiedFormatter) {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -621,6 +621,7 @@ public class Level implements java.io.Serializable {
private static void registerWithClassLoader(Level customLevel) {
PrivilegedAction<ClassLoader> pa = customLevel.getClass()::getClassLoader;
@SuppressWarnings("removal")
final ClassLoader cl = AccessController.doPrivileged(pa);
CUSTOM_LEVEL_CLV.computeIfAbsent(cl, (c, v) -> new ArrayList<>())
.add(customLevel);

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -152,6 +152,7 @@ import static jdk.internal.logger.DefaultLoggerFinder.isSystem;
* @since 1.4
*/
@SuppressWarnings("removal")
public class LogManager {
// The global LogManager object
private static final LogManager manager;
@ -2441,7 +2442,14 @@ public class LogManager {
*
* @throws SecurityException if a security manager exists and if
* the caller does not have LoggingPermission("control").
* @deprecated This method is only useful in conjunction with
* {@linkplain SecurityManager the Security Manager}, which is
* deprecated and subject to removal in a future release.
* Consequently, this method is also deprecated and subject to
* removal. There is no replacement for the Security Manager or this
* method.
*/
@Deprecated(since="17", forRemoval=true)
public void checkAccess() throws SecurityException {
checkPermission();
}

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -767,6 +767,7 @@ public class LogRecord implements java.io.Serializable {
/*
* CallerFinder is a stateful predicate.
*/
@SuppressWarnings("removal")
static final class CallerFinder implements Predicate<StackWalker.StackFrame> {
private static final StackWalker WALKER;
static {

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -634,6 +634,7 @@ public class Logger {
private static class SystemLoggerHelper {
static boolean disableCallerCheck = getBooleanProperty("sun.util.logging.disableCallerCheck");
private static boolean getBooleanProperty(final String key) {
@SuppressWarnings("removal")
String s = AccessController.doPrivileged(new PrivilegedAction<String>() {
@Override
public String run() {
@ -2206,6 +2207,7 @@ public class Logger {
// unnamed module class loader:
PrivilegedAction<ClassLoader> getModuleClassLoader =
() -> callerModule.getClassLoader();
@SuppressWarnings("removal")
ClassLoader moduleCL =
AccessController.doPrivileged(getModuleClassLoader);
// moduleCL can be null if the logger is created by a class

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2021, 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
@ -292,6 +292,7 @@ public class StreamHandler extends Handler {
// Package-private support for setting OutputStream
// with elevated privilege.
@SuppressWarnings("removal")
final void setOutputStreamPrivileged(final OutputStream out) {
AccessController.doPrivileged(new PrivilegedAction<Void>() {
@Override

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2021, 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
@ -403,6 +403,7 @@ public final class LoggingProviderImpl extends DefaultLoggerFinder {
* @param module the module for which the logger should be created.
* @return a Logger suitable for use in the given module.
*/
@SuppressWarnings("removal")
private static java.util.logging.Logger demandJULLoggerFor(final String name,
Module module) {
final LogManager manager = LogManager.getLogManager();
@ -429,6 +430,7 @@ public final class LoggingProviderImpl extends DefaultLoggerFinder {
*/
@Override
protected Logger demandLoggerFor(String name, Module module) {
@SuppressWarnings("removal")
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(LOGGERFINDER_PERMISSION);
@ -443,6 +445,7 @@ public final class LoggingProviderImpl extends DefaultLoggerFinder {
// Hook for tests
public static LogManagerAccess getLogManagerAccess() {
@SuppressWarnings("removal")
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(LOGGING_CONTROL_PERMISSION);
@ -455,6 +458,7 @@ public final class LoggingProviderImpl extends DefaultLoggerFinder {
private static volatile LogManagerAccess logManagerAccess;
public static void setLogManagerAccess(LogManagerAccess accesLoggers) {
@SuppressWarnings("removal")
final SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(LOGGING_CONTROL_PERMISSION);