Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8270859: Post JEP 411 refactoring: client libs with maximum covering …
…> 10K

Reviewed-by: serb
  • Loading branch information
wangweij committed Jul 27, 2021
1 parent c8af823 commit 90cd2fa
Show file tree
Hide file tree
Showing 22 changed files with 185 additions and 136 deletions.
17 changes: 16 additions & 1 deletion src/java.desktop/macosx/classes/com/apple/eio/FileManager.java
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));
Expand Down Expand Up @@ -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"));

Expand All @@ -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();
Expand All @@ -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);

Expand All @@ -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);

Expand Down
Expand Up @@ -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;

Expand All @@ -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() {
Expand Down
Expand Up @@ -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() {
Expand Down
Expand Up @@ -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() {
Expand Down
21 changes: 13 additions & 8 deletions src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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>) () -> {
Expand Down Expand Up @@ -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>) () -> {
Expand Down Expand Up @@ -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>) () -> {
Expand Down
22 changes: 12 additions & 10 deletions src/java.desktop/share/classes/java/awt/EventQueue.java
Expand Up @@ -94,7 +94,6 @@
*
* @since 1.1
*/
@SuppressWarnings("removal")
public class EventQueue {
private static final AtomicInteger threadInitNumber = new AtomicInteger();

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

private static boolean fxAppThreadIsDispatchThread;

static {
AWTAccessor.setEventQueueAccessor(
new AWTAccessor.EventQueueAccessor() {
Expand Down Expand Up @@ -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}.
*/
Expand Down Expand Up @@ -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);
Expand All @@ -750,6 +751,7 @@ public Void run() {
}
}

@SuppressWarnings("removal")
private static AccessControlContext getAccessControlContextFrom(Object src) {
return src instanceof Component ?
((Component)src).getAccessControlContext() :
Expand Down
8 changes: 2 additions & 6 deletions src/java.desktop/share/classes/javax/print/DocFlavor.java
Expand Up @@ -385,7 +385,6 @@
*
* @author Alan Kaminsky
*/
@SuppressWarnings("removal")
public class DocFlavor implements Serializable, Cloneable {

/**
Expand All @@ -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.
Expand Down
48 changes: 23 additions & 25 deletions src/java.desktop/share/classes/javax/swing/ImageIcon.java
Expand Up @@ -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
Expand All @@ -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();
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.
Expand Down

3 comments on commit 90cd2fa

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@mrserb
Copy link
Member

@mrserb mrserb commented on 90cd2fa Feb 9, 2023

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 90cd2fa Feb 9, 2023

Choose a reason for hiding this comment

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

@mrserb the backport was successfully created on the branch mrserb-backport-90cd2fa1 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 90cd2fa1 from the openjdk/jdk repository.

The commit being backported was authored by Weijun Wang on 27 Jul 2021 and was reviewed by Sergey Bylokhov.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-90cd2fa1:mrserb-backport-90cd2fa1
$ git checkout mrserb-backport-90cd2fa1
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev mrserb-backport-90cd2fa1

Please sign in to comment.