Skip to content

Commit e9b2c05

Browse files
committed
8269409: Post JEP 411 refactoring: core-libs with maximum covering > 10K
Reviewed-by: lancea, naoto
1 parent d0d26f5 commit e9b2c05

File tree

21 files changed

+229
-128
lines changed

21 files changed

+229
-128
lines changed

src/java.base/share/classes/java/io/ObjectInputFilter.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ enum Status {
560560
* fully qualified class name of the deserialization filter factory.
561561
* @since 9
562562
*/
563-
@SuppressWarnings("removal")
564563
final class Config {
565564
/**
566565
* Lock object for filter and filter factory.
@@ -628,19 +627,17 @@ final class Config {
628627
*/
629628

630629
// Get the values of the system properties, if they are defined
631-
String factoryClassName = StaticProperty.jdkSerialFilterFactory();
632-
if (factoryClassName == null) {
633-
// Fallback to security property
634-
factoryClassName = AccessController.doPrivileged((PrivilegedAction<String>) () ->
630+
@SuppressWarnings("removal")
631+
String factoryClassName = StaticProperty.jdkSerialFilterFactory() != null
632+
? StaticProperty.jdkSerialFilterFactory()
633+
: AccessController.doPrivileged((PrivilegedAction<String>) () ->
635634
Security.getProperty(SERIAL_FILTER_FACTORY_PROPNAME));
636-
}
637635

638-
String filterString = StaticProperty.jdkSerialFilter();
639-
if (filterString == null) {
640-
// Fallback to security property
641-
filterString = AccessController.doPrivileged((PrivilegedAction<String>) () ->
636+
@SuppressWarnings("removal")
637+
String filterString = StaticProperty.jdkSerialFilter() != null
638+
? StaticProperty.jdkSerialFilter()
639+
: AccessController.doPrivileged((PrivilegedAction<String>) () ->
642640
Security.getProperty(SERIAL_FILTER_PROPNAME));
643-
}
644641

645642
traceFilters = GetBooleanAction.privilegedGetProperty(SERIAL_FILTER_TRACE_PROPNAME);
646643

@@ -743,6 +740,7 @@ public static ObjectInputFilter getSerialFilter() {
743740
*/
744741
public static void setSerialFilter(ObjectInputFilter filter) {
745742
Objects.requireNonNull(filter, "filter");
743+
@SuppressWarnings("removal")
746744
SecurityManager sm = System.getSecurityManager();
747745
if (sm != null) {
748746
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);
@@ -836,6 +834,7 @@ static BinaryOperator<ObjectInputFilter> getSerialFilterFactorySingleton() {
836834
*/
837835
public static void setSerialFilterFactory(BinaryOperator<ObjectInputFilter> filterFactory) {
838836
Objects.requireNonNull(filterFactory, "filterFactory");
837+
@SuppressWarnings("removal")
839838
SecurityManager sm = System.getSecurityManager();
840839
if (sm != null) {
841840
sm.checkPermission(ObjectStreamConstants.SERIAL_FILTER_PERMISSION);

src/java.base/share/classes/java/net/IDN.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@
7272
* @since 1.6
7373
*
7474
*/
75-
@SuppressWarnings("removal")
7675
public final class IDN {
7776
/**
7877
* Flag to allow processing of unassigned code points
@@ -224,19 +223,15 @@ public static String toUnicode(String input) {
224223
private static StringPrep namePrep = null;
225224

226225
static {
227-
InputStream stream = null;
228-
229226
try {
230227
final String IDN_PROFILE = "/sun/net/idn/uidna.spp";
231-
if (System.getSecurityManager() != null) {
232-
stream = AccessController.doPrivileged(new PrivilegedAction<>() {
233-
public InputStream run() {
234-
return StringPrep.class.getResourceAsStream(IDN_PROFILE);
235-
}
236-
});
237-
} else {
238-
stream = StringPrep.class.getResourceAsStream(IDN_PROFILE);
239-
}
228+
@SuppressWarnings("removal")
229+
InputStream stream = System.getSecurityManager() != null
230+
? AccessController.doPrivileged(new PrivilegedAction<>() {
231+
public InputStream run() {
232+
return StringPrep.class.getResourceAsStream(IDN_PROFILE);
233+
}})
234+
: StringPrep.class.getResourceAsStream(IDN_PROFILE);
240235

241236
namePrep = new StringPrep(stream);
242237
stream.close();

src/java.base/share/classes/java/time/chrono/HijrahChronology.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,6 @@
202202
*
203203
* @since 1.8
204204
*/
205-
@SuppressWarnings("removal")
206205
public final class HijrahChronology extends AbstractChronology implements Serializable {
207206

208207
/**
@@ -291,8 +290,10 @@ public final class HijrahChronology extends AbstractChronology implements Serial
291290
AbstractChronology.registerChrono(INSTANCE, "islamic");
292291

293292
// custom config chronologies
294-
CONF_PATH = Path.of(AccessController.doPrivileged((PrivilegedAction<String>)
295-
() -> System.getProperty("java.home")), "conf", "chronology");
293+
@SuppressWarnings("removal")
294+
String javaHome = AccessController.doPrivileged((PrivilegedAction<String>)
295+
() -> System.getProperty("java.home"));
296+
CONF_PATH = Path.of(javaHome, "conf", "chronology");
296297
registerCustomChrono();
297298
}
298299

@@ -840,7 +841,7 @@ private static Properties readConfigProperties(final String chronologyId, final
840841
};
841842
FilePermission perm1 = new FilePermission("<<ALL FILES>>", "read");
842843
RuntimePermission perm2 = new RuntimePermission("accessSystemModules");
843-
try (InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
844+
try (@SuppressWarnings("removal") InputStream is = AccessController.doPrivileged(getResourceAction, null, perm1, perm2)) {
844845
if (is == null) {
845846
throw new RuntimeException("Hijrah calendar resource not found: " + resourceName);
846847
}
@@ -1035,6 +1036,7 @@ private int[] parseYMD(String string) {
10351036
* Look for Hijrah chronology variant properties files in
10361037
* <JAVA_HOME>/conf/chronology directory. Then register its chronology, if any.
10371038
*/
1039+
@SuppressWarnings("removal")
10381040
private static void registerCustomChrono() {
10391041
AccessController.doPrivileged(
10401042
(PrivilegedAction<Void>)() -> {

src/java.base/share/classes/java/time/zone/ZoneRulesProvider.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@
127127
*
128128
* @since 1.8
129129
*/
130-
@SuppressWarnings("removal")
131130
public abstract class ZoneRulesProvider {
132131

133132
/**
@@ -147,26 +146,28 @@ public abstract class ZoneRulesProvider {
147146
static {
148147
// if the property java.time.zone.DefaultZoneRulesProvider is
149148
// set then its value is the class name of the default provider
150-
final List<ZoneRulesProvider> loaded = new ArrayList<>();
151-
AccessController.doPrivileged(new PrivilegedAction<>() {
152-
public Object run() {
153-
String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider");
154-
if (prop != null) {
155-
try {
156-
Class<?> c = Class.forName(prop, true, ClassLoader.getSystemClassLoader());
157-
@SuppressWarnings("deprecation")
158-
ZoneRulesProvider provider = ZoneRulesProvider.class.cast(c.newInstance());
159-
registerProvider(provider);
160-
loaded.add(provider);
161-
} catch (Exception x) {
162-
throw new Error(x);
149+
@SuppressWarnings("removal")
150+
final List<ZoneRulesProvider> loaded =
151+
AccessController.doPrivileged(new PrivilegedAction<List<ZoneRulesProvider>>() {
152+
public List<ZoneRulesProvider> run() {
153+
List<ZoneRulesProvider> result = new ArrayList<>();
154+
String prop = System.getProperty("java.time.zone.DefaultZoneRulesProvider");
155+
if (prop != null) {
156+
try {
157+
Class<?> c = Class.forName(prop, true, ClassLoader.getSystemClassLoader());
158+
@SuppressWarnings("deprecation")
159+
ZoneRulesProvider provider = ZoneRulesProvider.class.cast(c.newInstance());
160+
registerProvider(provider);
161+
result.add(provider);
162+
} catch (Exception x) {
163+
throw new Error(x);
164+
}
165+
} else {
166+
registerProvider(new TzdbZoneRulesProvider());
167+
}
168+
return result;
163169
}
164-
} else {
165-
registerProvider(new TzdbZoneRulesProvider());
166-
}
167-
return null;
168-
}
169-
});
170+
});
170171

171172
ServiceLoader<ZoneRulesProvider> sl = ServiceLoader.load(ZoneRulesProvider.class, ClassLoader.getSystemClassLoader());
172173
Iterator<ZoneRulesProvider> it = sl.iterator();

src/java.base/share/classes/java/util/Currency.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@
111111
* @see java.math.BigDecimal
112112
* @since 1.4
113113
*/
114-
@SuppressWarnings("removal")
115114
public final class Currency implements Serializable {
116115

117116
@java.io.Serial
@@ -210,6 +209,11 @@ public final class Currency implements Serializable {
210209
private static final int VALID_FORMAT_VERSION = 3;
211210

212211
static {
212+
initStatic();
213+
}
214+
215+
@SuppressWarnings("removal")
216+
private static void initStatic() {
213217
AccessController.doPrivileged(new PrivilegedAction<>() {
214218
@Override
215219
public Void run() {

src/java.base/share/classes/java/util/concurrent/atomic/Striped64.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
* for classes supporting dynamic striping on 64bit values. The class
4848
* extends Number so that concrete subclasses must publicly do so.
4949
*/
50-
@SuppressWarnings({"removal","serial"})
50+
@SuppressWarnings("serial")
5151
abstract class Striped64 extends Number {
5252
/*
5353
* This class maintains a lazily-initialized table of atomically
@@ -382,12 +382,13 @@ else if (casBase(v = base, apply(fn, v, x)))
382382
private static final VarHandle THREAD_PROBE;
383383
static {
384384
try {
385-
MethodHandles.Lookup l = MethodHandles.lookup();
386-
BASE = l.findVarHandle(Striped64.class,
385+
MethodHandles.Lookup l1 = MethodHandles.lookup();
386+
BASE = l1.findVarHandle(Striped64.class,
387387
"base", long.class);
388-
CELLSBUSY = l.findVarHandle(Striped64.class,
388+
CELLSBUSY = l1.findVarHandle(Striped64.class,
389389
"cellsBusy", int.class);
390-
l = java.security.AccessController.doPrivileged(
390+
@SuppressWarnings("removal")
391+
MethodHandles.Lookup l2 = java.security.AccessController.doPrivileged(
391392
new java.security.PrivilegedAction<>() {
392393
public MethodHandles.Lookup run() {
393394
try {
@@ -396,7 +397,7 @@ public MethodHandles.Lookup run() {
396397
throw new ExceptionInInitializerError(e);
397398
}
398399
}});
399-
THREAD_PROBE = l.findVarHandle(Thread.class,
400+
THREAD_PROBE = l2.findVarHandle(Thread.class,
400401
"threadLocalRandomProbe", int.class);
401402
} catch (ReflectiveOperationException e) {
402403
throw new ExceptionInInitializerError(e);

src/java.base/share/classes/sun/net/www/MimeTable.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import java.util.Properties;
3434
import java.util.StringTokenizer;
3535

36-
@SuppressWarnings("removal")
3736
public class MimeTable implements FileNameMap {
3837
/** Keyed by content type, returns MimeEntries */
3938
private Hashtable<String, MimeEntry> entries
@@ -44,28 +43,15 @@ public class MimeTable implements FileNameMap {
4443
= new Hashtable<String, MimeEntry>();
4544

4645
// Will be reset if in the platform-specific data file
47-
private static String tempFileTemplate;
48-
49-
static {
46+
@SuppressWarnings("removal")
47+
private static String tempFileTemplate =
5048
java.security.AccessController.doPrivileged(
51-
new java.security.PrivilegedAction<Void>() {
52-
public Void run() {
53-
tempFileTemplate =
54-
System.getProperty("content.types.temp.file.template",
55-
"/tmp/%s");
56-
57-
mailcapLocations = new String[] {
58-
System.getProperty("user.mailcap"),
59-
StaticProperty.userHome() + "/.mailcap",
60-
"/etc/mailcap",
61-
"/usr/etc/mailcap",
62-
"/usr/local/etc/mailcap",
63-
};
64-
return null;
65-
}
66-
});
67-
}
68-
49+
new java.security.PrivilegedAction<String>() {
50+
public String run() {
51+
return System.getProperty("content.types.temp.file.template",
52+
"/tmp/%s");
53+
}
54+
});
6955

7056
private static final String filePreamble = "sun.net.www MIME content-types table";
7157
private static final String fileMagic = "#" + filePreamble;
@@ -77,6 +63,7 @@ public Void run() {
7763
private static class DefaultInstanceHolder {
7864
static final MimeTable defaultInstance = getDefaultInstance();
7965

66+
@SuppressWarnings("removal")
8067
static MimeTable getDefaultInstance() {
8168
return java.security.AccessController.doPrivileged(
8269
new java.security.PrivilegedAction<MimeTable>() {
@@ -220,7 +207,20 @@ public synchronized Enumeration<MimeEntry> elements() {
220207
// For backward compatibility -- mailcap format files
221208
// This is not currently used, but may in the future when we add ability
222209
// to read BOTH the properties format and the mailcap format.
223-
protected static String[] mailcapLocations;
210+
@SuppressWarnings("removal")
211+
protected static String[] mailcapLocations =
212+
java.security.AccessController.doPrivileged(
213+
new java.security.PrivilegedAction<String[]>() {
214+
public String[] run() {
215+
return new String[]{
216+
System.getProperty("user.mailcap"),
217+
StaticProperty.userHome() + "/.mailcap",
218+
"/etc/mailcap",
219+
"/usr/etc/mailcap",
220+
"/usr/local/etc/mailcap",
221+
};
222+
}
223+
});
224224

225225
public synchronized void load() {
226226
Properties entries = new Properties();
@@ -388,6 +388,7 @@ protected boolean saveAsProperties(File file) {
388388
properties.put("temp.file.template", tempFileTemplate);
389389
String tag;
390390
// Perform the property security check for user.name
391+
@SuppressWarnings("removal")
391392
SecurityManager sm = System.getSecurityManager();
392393
if (sm != null) {
393394
sm.checkPropertyAccess("user.name");

src/java.base/share/classes/sun/net/www/protocol/http/AuthenticationInfo.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@
5353
// policy in HttpURLConnection. A failure on baz.foo.com shouldn't
5454
// uncache foo.com!
5555

56-
@SuppressWarnings("removal")
5756
public abstract class AuthenticationInfo extends AuthCacheValue implements Cloneable {
5857

5958
@java.io.Serial
@@ -70,12 +69,10 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
7069
* repeatedly, via the Authenticator. Default is false, which means that this
7170
* behavior is switched off.
7271
*/
73-
static final boolean serializeAuth;
74-
static {
75-
serializeAuth = java.security.AccessController.doPrivileged(
72+
@SuppressWarnings("removal")
73+
static final boolean serializeAuth = java.security.AccessController.doPrivileged(
7674
new sun.security.action.GetBooleanAction(
7775
"http.auth.serializeRequests")).booleanValue();
78-
}
7976

8077
/* AuthCacheValue: */
8178

src/java.base/share/classes/sun/util/calendar/ZoneInfoFile.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
* <p>
5858
* @since 1.8
5959
*/
60-
@SuppressWarnings("removal")
6160
public final class ZoneInfoFile {
6261

6362
/**
@@ -249,6 +248,11 @@ private ZoneInfoFile() {
249248
.privilegedGetProperty("sun.timezone.ids.oldmapping", "false")
250249
.toLowerCase(Locale.ROOT);
251250
USE_OLDMAPPING = (oldmapping.equals("yes") || oldmapping.equals("true"));
251+
loadTZDB();
252+
}
253+
254+
@SuppressWarnings("removal")
255+
private static void loadTZDB() {
252256
AccessController.doPrivileged(new PrivilegedAction<Void>() {
253257
public Void run() {
254258
try {

0 commit comments

Comments
 (0)