Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8270859: Post JEP 411 refactoring: client libs with maximum covering > 10K #4815

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -53,9 +53,13 @@
*
* @since 1.4
*/
@SuppressWarnings("removal")
public class FileManager {
static {
loadOSXLibrary();
}

@SuppressWarnings("removal")
private static void loadOSXLibrary() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
@@ -132,6 +136,7 @@ public static int OSTypeToInt(String type) {
* @since 1.4
*/
public static void setFileTypeAndCreator(String filename, int type, int creator) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(filename);
@@ -146,6 +151,7 @@ public static void setFileTypeAndCreator(String filename, int type, int creator)
* @since 1.4
*/
public static void setFileType(String filename, int type) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(filename);
@@ -160,6 +166,7 @@ public static void setFileType(String filename, int type) throws IOException {
* @since 1.4
*/
public static void setFileCreator(String filename, int creator) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkWrite(filename);
@@ -174,6 +181,7 @@ public static void setFileCreator(String filename, int creator) throws IOExcepti
* @since 1.4
*/
public static int getFileType(String filename) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(filename);
@@ -188,6 +196,7 @@ public static int getFileType(String filename) throws IOException {
* @since 1.4
*/
public static int getFileCreator(String filename) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkRead(filename);
@@ -251,6 +260,7 @@ public static String findFolder(short domain, int folderType) throws FileNotFoun
* @since 1.4
*/
public static String findFolder(short domain, int folderType, boolean createIfNeeded) throws FileNotFoundException {
@SuppressWarnings("removal")
final SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new RuntimePermission("canExamineFileSystem"));
@@ -278,6 +288,7 @@ public static String findFolder(short domain, int folderType, boolean createIfNe
*/
@Deprecated
public static void openURL(String url) throws IOException {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) {
security.checkPermission(new RuntimePermission("canOpenURLs"));
@@ -329,6 +340,7 @@ public static String getResource(String resourceName, String subDirName, String

private static native String getNativeResourceFromBundle(String resourceName, String subDirName, String type) throws FileNotFoundException;
private static String getResourceFromBundle(String resourceName, String subDirName, String type) throws FileNotFoundException {
@SuppressWarnings("removal")
final SecurityManager security = System.getSecurityManager();
if (security != null) security.checkPermission(new RuntimePermission("canReadBundle"));

@@ -347,6 +359,7 @@ private static String getResourceFromBundle(String resourceName, String subDirNa
* @since Java for Mac OS X 10.5 Update 2 - 1.5
*/
public static String getPathToApplicationBundle() {
@SuppressWarnings("removal")
SecurityManager security = System.getSecurityManager();
if (security != null) security.checkPermission(new RuntimePermission("canReadBundle"));
return getNativePathToApplicationBundle();
@@ -368,6 +381,7 @@ public static boolean moveToTrash(final File file) throws FileNotFoundException
if (file == null) throw new FileNotFoundException();
final String fileName = file.getAbsolutePath();

@SuppressWarnings("removal")
final SecurityManager security = System.getSecurityManager();
if (security != null) security.checkDelete(fileName);

@@ -391,6 +405,7 @@ public static boolean revealInFinder(final File file) throws FileNotFoundExcepti
if (file == null || !file.exists()) throw new FileNotFoundException();
final String fileName = file.getAbsolutePath();

@SuppressWarnings("removal")
final SecurityManager security = System.getSecurityManager();
if (security != null) security.checkRead(fileName);

@@ -34,7 +34,7 @@

import com.apple.laf.AquaUtils.RecyclableSingleton;

@SuppressWarnings({"removal","serial"}) // JDK implementation class
@SuppressWarnings("serial") // JDK implementation class
class AquaFileView extends FileView {
private static final boolean DEBUG = false;

@@ -57,6 +57,11 @@ class AquaFileView extends FileView {
static final int kLSItemInfoExtensionIsHidden = 0x00100000; /* Item has a hidden extension*/

static {
loadOSXUILibrary();
}

@SuppressWarnings("removal")
private static void loadOSXUILibrary() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
@@ -36,12 +36,17 @@
import sun.lwawt.LWToolkit;
import sun.lwawt.macosx.*;

@SuppressWarnings({"removal","serial"}) // JDK implementation class
@SuppressWarnings("serial") // JDK implementation class
final class ScreenMenu extends Menu
implements ContainerListener, ComponentListener,
ScreenMenuPropertyHandler {

static {
loadAWTLibrary();
}

@SuppressWarnings("removal")
private static void loadAWTLibrary() {
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
@@ -62,12 +62,16 @@
import sun.awt.AWTAccessor;
import sun.lwawt.LWWindowPeer;

@SuppressWarnings("removal")
class CAccessibility implements PropertyChangeListener {
private static Set<String> ignoredRoles;

static {
// Need to load the native library for this code.
loadAWTLibrary();
}

@SuppressWarnings("removal")
private static void loadAWTLibrary() {
// Need to load the native library for this code.
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<Void>() {
public Void run() {
@@ -131,7 +131,6 @@ final class NamedCursor extends Cursor {
/**
* Mac OS X Cocoa-based AWT Toolkit.
*/
@SuppressWarnings("removal")
public final class LWCToolkit extends LWToolkit {
// While it is possible to enumerate all mouse devices
// and query them for the number of buttons, the code
@@ -147,6 +146,7 @@ public final class LWCToolkit extends LWToolkit {
static {
System.err.flush();

@SuppressWarnings("removal")
ResourceBundle platformResources = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction<ResourceBundle>() {
@Override
@@ -176,20 +176,23 @@ public ResourceBundle run() {
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
inAWT = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false"));
}
});
}

/*
* If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
* If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
*/
private static final boolean inAWT;
@SuppressWarnings("removal")
private static final boolean inAWT
= AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
@Override
public Boolean run() {
return !Boolean.parseBoolean(
System.getProperty("javafx.embed.singleThread", "false"));
}
});

@SuppressWarnings("removal")
public LWCToolkit() {
final String extraButtons = "sun.awt.enableExtraMouseButtons";
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -248,6 +251,7 @@ public static Color getAppleColor(int color) {
}

// This is only called from native code.
@SuppressWarnings("removal")
static void systemColorsChanged() {
EventQueue.invokeLater(() -> {
AccessController.doPrivileged( (PrivilegedAction<Object>) () -> {
@@ -586,6 +590,7 @@ public boolean isAlwaysOnTopSupported() {
private static final String APPKIT_THREAD_NAME = "AppKit Thread";

// Intended to be called from the LWCToolkit.m only.
@SuppressWarnings("removal")
private static void installToolkitThreadInJava() {
Thread.currentThread().setName(APPKIT_THREAD_NAME);
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
@@ -94,7 +94,6 @@
*
* @since 1.1
*/
@SuppressWarnings("removal")
public class EventQueue {
private static final AtomicInteger threadInitNumber = new AtomicInteger();

@@ -192,8 +191,6 @@ private static final PlatformLogger getEventLog() {
return eventLog;
}

private static boolean fxAppThreadIsDispatchThread;

static {
AWTAccessor.setEventQueueAccessor(
new AWTAccessor.EventQueueAccessor() {
@@ -230,15 +227,16 @@ public long getMostRecentEventTime(EventQueue eventQueue) {
return eventQueue.getMostRecentEventTimeImpl();
}
});
AccessController.doPrivileged(new PrivilegedAction<Object>() {
public Object run() {
fxAppThreadIsDispatchThread =
"true".equals(System.getProperty("javafx.embed.singleThread"));
return null;
}
});
}

@SuppressWarnings("removal")
private static boolean fxAppThreadIsDispatchThread =
AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
public Boolean run() {
return "true".equals(System.getProperty("javafx.embed.singleThread"));
}
});

/**
* Initializes a new instance of {@code EventQueue}.
*/
@@ -734,8 +732,11 @@ public void run() {
}
};

@SuppressWarnings("removal")
final AccessControlContext stack = AccessController.getContext();
@SuppressWarnings("removal")
final AccessControlContext srcAcc = getAccessControlContextFrom(src);
@SuppressWarnings("removal")
final AccessControlContext eventAcc = event.getAccessControlContext();
if (srcAcc == null) {
javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
@@ -750,6 +751,7 @@ public Void run() {
}
}

@SuppressWarnings("removal")
private static AccessControlContext getAccessControlContextFrom(Object src) {
return src instanceof Component ?
((Component)src).getAccessControlContext() :
@@ -385,7 +385,6 @@
*
* @author Alan Kaminsky
*/
@SuppressWarnings("removal")
public class DocFlavor implements Serializable, Cloneable {

/**
@@ -405,13 +404,10 @@ public class DocFlavor implements Serializable, Cloneable {
* This is the charset for all the "HOST" pre-defined {@code DocFlavors} in
* the executing VM.
*/
public static final String hostEncoding;

static {
hostEncoding =
@SuppressWarnings("removal")
public static final String hostEncoding =
java.security.AccessController.doPrivileged(
new sun.security.action.GetPropertyAction("file.encoding"));
}

/**
* MIME type.
@@ -85,7 +85,7 @@
* @author Lynn Monsanto
* @since 1.2
*/
@SuppressWarnings({"removal","serial"}) // Same-version serialization only
@SuppressWarnings("serial") // Same-version serialization only
public class ImageIcon implements Icon, Serializable, Accessible {
/* Keep references to the filename and location so that
* alternate persistence schemes have the option to archive
@@ -105,39 +105,37 @@ public class ImageIcon implements Icon, Serializable, Accessible {
* It is left for backward compatibility only.
* @deprecated since 1.8
*/
@SuppressWarnings("removal")
@Deprecated
protected static final Component component;
protected static final Component component
= AccessController.doPrivileged(new PrivilegedAction<Component>() {
public Component run() {
try {
final Component component = createNoPermsComponent();

// 6482575 - clear the appContext field so as not to leak it
AWTAccessor.getComponentAccessor().
setAppContext(component, null);

return component;
} catch (Throwable e) {
// We don't care about component.
// So don't prevent class initialisation.
e.printStackTrace();
Copy link

@Vest Vest Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not the reviewer, but I am curious. If we do not care about the exception, is it a right way to just print it to the console as it is? If people use loggers, they won’t be able to capture this stack trace.
thank you for your answer in advance.
p.s. I know it is not your code, but isn’t it a suitable time to improve this part?

Copy link
Contributor

@prrace prrace Jul 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that has nothing to do with what is being done here so it is a terrible time to do it.

Copy link
Member

@kevinrushforth kevinrushforth Jul 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. A refactoring change like this is the wrong time to make any unrelated changes. If such changes are a good idea, they should be done in a different bug with a separate pull request.

return null;
}
}
});

/**
* Do not use this shared media tracker, which is used to load images.
* It is left for backward compatibility only.
* @deprecated since 1.8
*/
@Deprecated
protected static final MediaTracker tracker;

static {
component = AccessController.doPrivileged(new PrivilegedAction<Component>() {
public Component run() {
try {
final Component component = createNoPermsComponent();

// 6482575 - clear the appContext field so as not to leak it
AWTAccessor.getComponentAccessor().
setAppContext(component, null);

return component;
} catch (Throwable e) {
// We don't care about component.
// So don't prevent class initialisation.
e.printStackTrace();
return null;
}
}
});
tracker = new MediaTracker(component);
}
protected static final MediaTracker tracker = new MediaTracker(component);

@SuppressWarnings("removal")
private static Component createNoPermsComponent() {
// 7020198 - set acc field to no permissions and no subject
// Note, will have appContext set.