From 87be63f85dbbfd8695817a913ef2b2ae5b0d78e9 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Thu, 21 Nov 2024 16:18:16 +0000 Subject: [PATCH] 8344659: Some uses of GetPropertyAction were not removed from java.io and java.nio Reviewed-by: lancea, rriggs, iris, dfuchs --- .../macosx/classes/sun/nio/fs/MacOSXFileSystem.java | 5 ++--- .../classes/sun/nio/fs/MacOSXFileSystemProvider.java | 3 +-- src/java.base/share/classes/java/io/Console.java | 3 +-- src/java.base/share/classes/sun/nio/ch/Poller.java | 5 ++--- src/java.base/share/classes/sun/nio/cs/GB18030.java | 5 ++--- .../share/classes/sun/nio/fs/AbstractWatchKey.java | 3 +-- src/java.base/share/classes/sun/nio/fs/Util.java | 6 +++--- .../windows/classes/sun/nio/ch/FileDispatcherImpl.java | 5 ++--- .../windows/classes/sun/nio/fs/WindowsFileAttributes.java | 7 +++---- 9 files changed, 17 insertions(+), 25 deletions(-) diff --git a/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java b/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java index 9303c713bf2..9b1c5096719 100644 --- a/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java +++ b/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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,7 +26,6 @@ package sun.nio.fs; import java.util.regex.Pattern; -import sun.security.action.GetPropertyAction; import static sun.nio.fs.MacOSXNativeDispatcher.*; @@ -43,7 +42,7 @@ class MacOSXFileSystem extends BsdFileSystem { static { final String name = PROPERTY_NORMALIZE_FILE_PATHS; - String value = GetPropertyAction.privilegedGetProperty(name); + String value = System.getProperty(name); NORMALIZE_FILE_PATHS = (value != null) && ("".equals(value) || Boolean.parseBoolean(value)); } diff --git a/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java b/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java index 256a9b5e613..2540478dfca 100644 --- a/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java +++ b/src/java.base/macosx/classes/sun/nio/fs/MacOSXFileSystemProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -28,7 +28,6 @@ package sun.nio.fs; import java.nio.file.Path; import java.nio.file.spi.FileTypeDetector; import jdk.internal.util.StaticProperty; -import sun.security.action.GetPropertyAction; /** * MacOSX implementation of FileSystemProvider diff --git a/src/java.base/share/classes/java/io/Console.java b/src/java.base/share/classes/java/io/Console.java index 3881b2380ad..4f919c064b9 100644 --- a/src/java.base/share/classes/java/io/Console.java +++ b/src/java.base/share/classes/java/io/Console.java @@ -33,7 +33,6 @@ import jdk.internal.io.JdkConsoleImpl; import jdk.internal.io.JdkConsoleProvider; import jdk.internal.javac.PreviewFeature; import sun.nio.cs.UTF_8; -import sun.security.action.GetPropertyAction; /** * Methods to access the character-based console device, if any, associated @@ -646,7 +645,7 @@ public sealed class Console implements Flushable permits ProxyingConsole { private static final boolean istty = istty(); static final Charset CHARSET = - Charset.forName(GetPropertyAction.privilegedGetProperty("stdout.encoding"), UTF_8.INSTANCE); + Charset.forName(System.getProperty("stdout.encoding"), UTF_8.INSTANCE); private static final Console cons = instantiateConsole(); static { // Set up JavaIOAccess in SharedSecrets diff --git a/src/java.base/share/classes/sun/nio/ch/Poller.java b/src/java.base/share/classes/sun/nio/ch/Poller.java index ec45a398176..d25dfec7f42 100644 --- a/src/java.base/share/classes/sun/nio/ch/Poller.java +++ b/src/java.base/share/classes/sun/nio/ch/Poller.java @@ -36,7 +36,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.locks.LockSupport; import java.util.function.BooleanSupplier; import jdk.internal.misc.InnocuousThread; -import sun.security.action.GetPropertyAction; /** * Polls file descriptors. Virtual threads invoke the poll method to park @@ -305,7 +304,7 @@ public abstract class Poller { Pollers() throws IOException { PollerProvider provider = PollerProvider.provider(); Poller.Mode mode; - String s = GetPropertyAction.privilegedGetProperty("jdk.pollerMode"); + String s = System.getProperty("jdk.pollerMode"); if (s != null) { if (s.equalsIgnoreCase(Mode.SYSTEM_THREADS.name()) || s.equals("1")) { mode = Mode.SYSTEM_THREADS; @@ -418,7 +417,7 @@ public abstract class Poller { * is not a power of 2. */ private static int pollerCount(String propName, int defaultCount) { - String s = GetPropertyAction.privilegedGetProperty(propName); + String s = System.getProperty(propName); int count = (s != null) ? Integer.parseInt(s) : defaultCount; // check power of 2 diff --git a/src/java.base/share/classes/sun/nio/cs/GB18030.java b/src/java.base/share/classes/sun/nio/cs/GB18030.java index 362553a5dbb..2fc58b4ce5e 100644 --- a/src/java.base/share/classes/sun/nio/cs/GB18030.java +++ b/src/java.base/share/classes/sun/nio/cs/GB18030.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 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,7 +36,6 @@ import java.nio.charset.CharsetEncoder; import java.nio.charset.CoderResult; import jdk.internal.misc.VM; import sun.nio.cs.Surrogate; -import sun.security.action.GetPropertyAction; public class GB18030 extends Charset @@ -49,7 +48,7 @@ public class GB18030 // as the system property is not ready to be read in that case. static final boolean IS_2000 = VM.initLevel() >= 1 && - "2000".equals(GetPropertyAction.privilegedGetProperty("jdk.charset.GB18030", "")); + "2000".equals(System.getProperty("jdk.charset.GB18030", "")); public GB18030() { super("GB18030", StandardCharsets.aliases_GB18030()); diff --git a/src/java.base/share/classes/sun/nio/fs/AbstractWatchKey.java b/src/java.base/share/classes/sun/nio/fs/AbstractWatchKey.java index bdb7920b20a..a598302e165 100644 --- a/src/java.base/share/classes/sun/nio/fs/AbstractWatchKey.java +++ b/src/java.base/share/classes/sun/nio/fs/AbstractWatchKey.java @@ -29,7 +29,6 @@ import java.nio.file.*; import java.util.*; import jdk.internal.util.ArraysSupport; -import sun.security.action.GetPropertyAction; /** * Base implementation class for watch keys. @@ -44,7 +43,7 @@ abstract class AbstractWatchKey implements WatchKey { */ static final int MAX_EVENT_LIST_SIZE; static { - String rawValue = GetPropertyAction.privilegedGetProperty( + String rawValue = System.getProperty( "jdk.nio.file.WatchService.maxEventsPerPoll", String.valueOf(DEFAULT_MAX_EVENT_LIST_SIZE)); int intValue; diff --git a/src/java.base/share/classes/sun/nio/fs/Util.java b/src/java.base/share/classes/sun/nio/fs/Util.java index 94a5def1e85..01b5238a6b2 100644 --- a/src/java.base/share/classes/sun/nio/fs/Util.java +++ b/src/java.base/share/classes/sun/nio/fs/Util.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 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 @@ -28,7 +28,7 @@ package sun.nio.fs; import java.util.*; import java.nio.file.*; import java.nio.charset.Charset; -import sun.security.action.GetPropertyAction; +import jdk.internal.util.StaticProperty; /** * Utility methods @@ -38,7 +38,7 @@ class Util { private Util() { } private static final Charset jnuEncoding = Charset.forName( - GetPropertyAction.privilegedGetProperty("sun.jnu.encoding")); + StaticProperty.jnuEncoding()); /** * Returns {@code Charset} corresponding to the sun.jnu.encoding property diff --git a/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java b/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java index 6b7a81c2e85..146e1c17564 100644 --- a/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java +++ b/src/java.base/windows/classes/sun/nio/ch/FileDispatcherImpl.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.nio.CharBuffer; import jdk.internal.access.JavaIOFileDescriptorAccess; import jdk.internal.access.SharedSecrets; -import sun.security.action.GetPropertyAction; class FileDispatcherImpl extends FileDispatcher { private static final int MAP_INVALID = -1; @@ -189,8 +188,8 @@ class FileDispatcherImpl extends FileDispatcher { } static boolean isFastFileTransferRequested() { - String fileTransferProp = GetPropertyAction - .privilegedGetProperty("jdk.nio.enableFastFileTransfer", "false"); + String fileTransferProp = + System.getProperty("jdk.nio.enableFastFileTransfer", "false"); return fileTransferProp.isEmpty() ? true : Boolean.parseBoolean(fileTransferProp); } diff --git a/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java b/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java index e442c49eadf..6e544b1c926 100644 --- a/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java +++ b/src/java.base/windows/classes/sun/nio/fs/WindowsFileAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -28,7 +28,6 @@ package sun.nio.fs; import java.nio.file.attribute.*; import java.util.concurrent.TimeUnit; import jdk.internal.misc.Unsafe; -import sun.security.action.GetPropertyAction; import static sun.nio.fs.WindowsNativeDispatcher.*; import static sun.nio.fs.WindowsConstants.*; @@ -115,8 +114,8 @@ class WindowsFileAttributes // indicates if accurate metadata is required (interesting on NTFS only) private static final boolean ensureAccurateMetadata; static { - String propValue = GetPropertyAction.privilegedGetProperty( - "sun.nio.fs.ensureAccurateMetadata", "false"); + String propValue = + System.getProperty("sun.nio.fs.ensureAccurateMetadata", "false"); ensureAccurateMetadata = propValue.isEmpty() ? true : Boolean.parseBoolean(propValue); }