Skip to content

Commit c118b0e

Browse files
committed
8270859: Post JEP 411 refactoring: client libs with maximum covering > 10K
Backport-of: 90cd2fa16458dcc3e36171fa4bf21f26bc92b168
1 parent 1ad9e68 commit c118b0e

22 files changed

+185
-136
lines changed

src/java.desktop/macosx/classes/com/apple/eio/FileManager.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@
5353
*
5454
* @since 1.4
5555
*/
56-
@SuppressWarnings("removal")
5756
public class FileManager {
5857
static {
58+
loadOSXLibrary();
59+
}
60+
61+
@SuppressWarnings("removal")
62+
private static void loadOSXLibrary() {
5963
java.security.AccessController.doPrivileged(
6064
new java.security.PrivilegedAction<Void>() {
6165
public Void run() {
@@ -132,6 +136,7 @@ public static int OSTypeToInt(String type) {
132136
* @since 1.4
133137
*/
134138
public static void setFileTypeAndCreator(String filename, int type, int creator) throws IOException {
139+
@SuppressWarnings("removal")
135140
SecurityManager security = System.getSecurityManager();
136141
if (security != null) {
137142
security.checkWrite(filename);
@@ -146,6 +151,7 @@ public static void setFileTypeAndCreator(String filename, int type, int creator)
146151
* @since 1.4
147152
*/
148153
public static void setFileType(String filename, int type) throws IOException {
154+
@SuppressWarnings("removal")
149155
SecurityManager security = System.getSecurityManager();
150156
if (security != null) {
151157
security.checkWrite(filename);
@@ -160,6 +166,7 @@ public static void setFileType(String filename, int type) throws IOException {
160166
* @since 1.4
161167
*/
162168
public static void setFileCreator(String filename, int creator) throws IOException {
169+
@SuppressWarnings("removal")
163170
SecurityManager security = System.getSecurityManager();
164171
if (security != null) {
165172
security.checkWrite(filename);
@@ -174,6 +181,7 @@ public static void setFileCreator(String filename, int creator) throws IOExcepti
174181
* @since 1.4
175182
*/
176183
public static int getFileType(String filename) throws IOException {
184+
@SuppressWarnings("removal")
177185
SecurityManager security = System.getSecurityManager();
178186
if (security != null) {
179187
security.checkRead(filename);
@@ -188,6 +196,7 @@ public static int getFileType(String filename) throws IOException {
188196
* @since 1.4
189197
*/
190198
public static int getFileCreator(String filename) throws IOException {
199+
@SuppressWarnings("removal")
191200
SecurityManager security = System.getSecurityManager();
192201
if (security != null) {
193202
security.checkRead(filename);
@@ -251,6 +260,7 @@ public static String findFolder(short domain, int folderType) throws FileNotFoun
251260
* @since 1.4
252261
*/
253262
public static String findFolder(short domain, int folderType, boolean createIfNeeded) throws FileNotFoundException {
263+
@SuppressWarnings("removal")
254264
final SecurityManager security = System.getSecurityManager();
255265
if (security != null) {
256266
security.checkPermission(new RuntimePermission("canExamineFileSystem"));
@@ -278,6 +288,7 @@ public static String findFolder(short domain, int folderType, boolean createIfNe
278288
*/
279289
@Deprecated
280290
public static void openURL(String url) throws IOException {
291+
@SuppressWarnings("removal")
281292
SecurityManager security = System.getSecurityManager();
282293
if (security != null) {
283294
security.checkPermission(new RuntimePermission("canOpenURLs"));
@@ -329,6 +340,7 @@ public static String getResource(String resourceName, String subDirName, String
329340

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

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

384+
@SuppressWarnings("removal")
371385
final SecurityManager security = System.getSecurityManager();
372386
if (security != null) security.checkDelete(fileName);
373387

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

408+
@SuppressWarnings("removal")
394409
final SecurityManager security = System.getSecurityManager();
395410
if (security != null) security.checkRead(fileName);
396411

src/java.desktop/macosx/classes/com/apple/laf/AquaFileView.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
import com.apple.laf.AquaUtils.RecyclableSingleton;
3636

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

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

5959
static {
60+
loadOSXUILibrary();
61+
}
62+
63+
@SuppressWarnings("removal")
64+
private static void loadOSXUILibrary() {
6065
java.security.AccessController.doPrivileged(
6166
new java.security.PrivilegedAction<Void>() {
6267
public Void run() {

src/java.desktop/macosx/classes/com/apple/laf/ScreenMenu.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,17 @@
3636
import sun.lwawt.LWToolkit;
3737
import sun.lwawt.macosx.*;
3838

39-
@SuppressWarnings({"removal","serial"}) // JDK implementation class
39+
@SuppressWarnings("serial") // JDK implementation class
4040
final class ScreenMenu extends Menu
4141
implements ContainerListener, ComponentListener,
4242
ScreenMenuPropertyHandler {
4343

4444
static {
45+
loadAWTLibrary();
46+
}
47+
48+
@SuppressWarnings("removal")
49+
private static void loadAWTLibrary() {
4550
java.security.AccessController.doPrivileged(
4651
new java.security.PrivilegedAction<Void>() {
4752
public Void run() {

src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,16 @@
6767
import sun.awt.AWTAccessor;
6868
import sun.lwawt.LWWindowPeer;
6969

70-
@SuppressWarnings("removal")
7170
class CAccessibility implements PropertyChangeListener {
7271
private static Set<String> ignoredRoles;
7372

7473
static {
75-
// Need to load the native library for this code.
74+
loadAWTLibrary();
75+
}
76+
77+
@SuppressWarnings("removal")
78+
private static void loadAWTLibrary() {
79+
// Need to load the native library for this code.
7680
java.security.AccessController.doPrivileged(
7781
new java.security.PrivilegedAction<Void>() {
7882
public Void run() {

src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ final class NamedCursor extends Cursor {
131131
/**
132132
* Mac OS X Cocoa-based AWT Toolkit.
133133
*/
134-
@SuppressWarnings("removal")
135134
public final class LWCToolkit extends LWToolkit {
136135
// While it is possible to enumerate all mouse devices
137136
// and query them for the number of buttons, the code
@@ -147,6 +146,7 @@ public final class LWCToolkit extends LWToolkit {
147146
static {
148147
System.err.flush();
149148

149+
@SuppressWarnings("removal")
150150
ResourceBundle platformResources = java.security.AccessController.doPrivileged(
151151
new java.security.PrivilegedAction<ResourceBundle>() {
152152
@Override
@@ -176,20 +176,23 @@ public ResourceBundle run() {
176176
if (!GraphicsEnvironment.isHeadless()) {
177177
initIDs();
178178
}
179-
inAWT = AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
180-
@Override
181-
public Boolean run() {
182-
return !Boolean.parseBoolean(System.getProperty("javafx.embed.singleThread", "false"));
183-
}
184-
});
185179
}
186180

187181
/*
188182
* If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
189183
* If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
190184
*/
191-
private static final boolean inAWT;
185+
@SuppressWarnings("removal")
186+
private static final boolean inAWT
187+
= AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
188+
@Override
189+
public Boolean run() {
190+
return !Boolean.parseBoolean(
191+
System.getProperty("javafx.embed.singleThread", "false"));
192+
}
193+
});
192194

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

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

588592
// Intended to be called from the LWCToolkit.m only.
593+
@SuppressWarnings("removal")
589594
private static void installToolkitThreadInJava() {
590595
Thread.currentThread().setName(APPKIT_THREAD_NAME);
591596
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {

src/java.desktop/share/classes/java/awt/EventQueue.java

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@
9494
*
9595
* @since 1.1
9696
*/
97-
@SuppressWarnings("removal")
9897
public class EventQueue {
9998
private static final AtomicInteger threadInitNumber = new AtomicInteger();
10099

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

195-
private static boolean fxAppThreadIsDispatchThread;
196-
197194
static {
198195
AWTAccessor.setEventQueueAccessor(
199196
new AWTAccessor.EventQueueAccessor() {
@@ -230,15 +227,16 @@ public long getMostRecentEventTime(EventQueue eventQueue) {
230227
return eventQueue.getMostRecentEventTimeImpl();
231228
}
232229
});
233-
AccessController.doPrivileged(new PrivilegedAction<Object>() {
234-
public Object run() {
235-
fxAppThreadIsDispatchThread =
236-
"true".equals(System.getProperty("javafx.embed.singleThread"));
237-
return null;
238-
}
239-
});
240230
}
241231

232+
@SuppressWarnings("removal")
233+
private static boolean fxAppThreadIsDispatchThread =
234+
AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
235+
public Boolean run() {
236+
return "true".equals(System.getProperty("javafx.embed.singleThread"));
237+
}
238+
});
239+
242240
/**
243241
* Initializes a new instance of {@code EventQueue}.
244242
*/
@@ -734,8 +732,11 @@ public void run() {
734732
}
735733
};
736734

735+
@SuppressWarnings("removal")
737736
final AccessControlContext stack = AccessController.getContext();
737+
@SuppressWarnings("removal")
738738
final AccessControlContext srcAcc = getAccessControlContextFrom(src);
739+
@SuppressWarnings("removal")
739740
final AccessControlContext eventAcc = event.getAccessControlContext();
740741
if (srcAcc == null) {
741742
javaSecurityAccess.doIntersectionPrivilege(action, stack, eventAcc);
@@ -750,6 +751,7 @@ public Void run() {
750751
}
751752
}
752753

754+
@SuppressWarnings("removal")
753755
private static AccessControlContext getAccessControlContextFrom(Object src) {
754756
return src instanceof Component ?
755757
((Component)src).getAccessControlContext() :

src/java.desktop/share/classes/javax/print/DocFlavor.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@
385385
*
386386
* @author Alan Kaminsky
387387
*/
388-
@SuppressWarnings("removal")
389388
public class DocFlavor implements Serializable, Cloneable {
390389

391390
/**
@@ -405,13 +404,10 @@ public class DocFlavor implements Serializable, Cloneable {
405404
* This is the charset for all the "HOST" pre-defined {@code DocFlavors} in
406405
* the executing VM.
407406
*/
408-
public static final String hostEncoding;
409-
410-
static {
411-
hostEncoding =
407+
@SuppressWarnings("removal")
408+
public static final String hostEncoding =
412409
java.security.AccessController.doPrivileged(
413410
new sun.security.action.GetPropertyAction("file.encoding"));
414-
}
415411

416412
/**
417413
* MIME type.

src/java.desktop/share/classes/javax/swing/ImageIcon.java

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
* @author Lynn Monsanto
8686
* @since 1.2
8787
*/
88-
@SuppressWarnings({"removal","serial"}) // Same-version serialization only
88+
@SuppressWarnings("serial") // Same-version serialization only
8989
public class ImageIcon implements Icon, Serializable, Accessible {
9090
/* Keep references to the filename and location so that
9191
* alternate persistence schemes have the option to archive
@@ -105,39 +105,37 @@ public class ImageIcon implements Icon, Serializable, Accessible {
105105
* It is left for backward compatibility only.
106106
* @deprecated since 1.8
107107
*/
108+
@SuppressWarnings("removal")
108109
@Deprecated
109-
protected static final Component component;
110+
protected static final Component component
111+
= AccessController.doPrivileged(new PrivilegedAction<Component>() {
112+
public Component run() {
113+
try {
114+
final Component component = createNoPermsComponent();
115+
116+
// 6482575 - clear the appContext field so as not to leak it
117+
AWTAccessor.getComponentAccessor().
118+
setAppContext(component, null);
119+
120+
return component;
121+
} catch (Throwable e) {
122+
// We don't care about component.
123+
// So don't prevent class initialisation.
124+
e.printStackTrace();
125+
return null;
126+
}
127+
}
128+
});
110129

111130
/**
112131
* Do not use this shared media tracker, which is used to load images.
113132
* It is left for backward compatibility only.
114133
* @deprecated since 1.8
115134
*/
116135
@Deprecated
117-
protected static final MediaTracker tracker;
118-
119-
static {
120-
component = AccessController.doPrivileged(new PrivilegedAction<Component>() {
121-
public Component run() {
122-
try {
123-
final Component component = createNoPermsComponent();
124-
125-
// 6482575 - clear the appContext field so as not to leak it
126-
AWTAccessor.getComponentAccessor().
127-
setAppContext(component, null);
128-
129-
return component;
130-
} catch (Throwable e) {
131-
// We don't care about component.
132-
// So don't prevent class initialisation.
133-
e.printStackTrace();
134-
return null;
135-
}
136-
}
137-
});
138-
tracker = new MediaTracker(component);
139-
}
136+
protected static final MediaTracker tracker = new MediaTracker(component);
140137

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

0 commit comments

Comments
 (0)