Skip to content

Commit cb66269

Browse files
tomballcopybara-github
authored andcommitted
Removes JRE calls to System.getSecurityManager() and code blocks that depend on a non-null being returned, since on j2objc and Android that method always returns null.
PiperOrigin-RevId: 733090121
1 parent d558739 commit cb66269

File tree

63 files changed

+879
-870
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+879
-870
lines changed

jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ClassLoaderUtil.java

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
*/
1010
package android.icu.impl;
1111

12-
import java.security.AccessController;
13-
import java.security.PrivilegedAction;
12+
// import java.security.AccessController;
13+
// import java.security.PrivilegedAction;
1414

1515

1616
/**
@@ -53,18 +53,18 @@ private static ClassLoader getBootstrapClassLoader() {
5353
if (BOOTSTRAP_CLASSLOADER == null) {
5454
synchronized(ClassLoaderUtil.class) {
5555
if (BOOTSTRAP_CLASSLOADER == null) {
56-
ClassLoader cl = null;
57-
if (System.getSecurityManager() != null) {
58-
cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
59-
@Override
60-
public BootstrapClassLoader run() {
61-
return new BootstrapClassLoader();
62-
}
63-
});
64-
} else {
65-
cl = new BootstrapClassLoader();
66-
}
67-
BOOTSTRAP_CLASSLOADER = cl;
56+
// ClassLoader cl = null;
57+
// if (System.getSecurityManager() != null) {
58+
// cl = AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
59+
// @Override
60+
// public BootstrapClassLoader run() {
61+
// return new BootstrapClassLoader();
62+
// }
63+
// });
64+
// } else {
65+
// cl = new BootstrapClassLoader();
66+
// }
67+
BOOTSTRAP_CLASSLOADER = new BootstrapClassLoader();
6868
}
6969
}
7070
}

jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ public static String get(String name) {
6060
* exist, <code>def</code> is returned.
6161
*/
6262
public static String get(String name, String def) {
63+
/* SecurityManager is not supported on j2objc.
6364
String val = null;
6465
final String fname = name;
66+
6567
if (System.getSecurityManager() != null) {
6668
try {
6769
val = AccessController.doPrivileged(new PrivilegedAction<String>() {
@@ -77,7 +79,9 @@ public String run() {
7779
} else {
7880
val = System.getProperty(name);
7981
}
82+
*/
8083

84+
String val = System.getProperty(name);
8185
if (val == null) {
8286
val = CONFIG_PROPS.getProperty(name, def);
8387
}

jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/impl/ICUData.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
import java.io.IOException;
1616
import java.io.InputStream;
1717
import java.net.URL;
18-
import java.security.AccessController;
19-
import java.security.PrivilegedAction;
18+
// import java.security.AccessController;
19+
// import java.security.PrivilegedAction;
2020
import java.util.MissingResourceException;
2121
import java.util.logging.Logger;
2222

@@ -104,6 +104,7 @@ public final class ICUData {
104104
Logger.getLogger(ICUData.class.getName()) : null;
105105

106106
public static boolean exists(final String resourceName) {
107+
/* SecurityManager is not supported on j2objc.
107108
URL i = null;
108109
if (System.getSecurityManager() != null) {
109110
i = AccessController.doPrivileged(new PrivilegedAction<URL>() {
@@ -115,10 +116,13 @@ public URL run() {
115116
} else {
116117
i = ICUData.class.getResource(resourceName);
117118
}
119+
*/
120+
URL i = ICUData.class.getResource(resourceName);
118121
return i != null;
119122
}
120123

121124
private static InputStream getStream(final Class<?> root, final String resourceName, boolean required) {
125+
/* SecurityManager is not supported on j2objc.
122126
InputStream i = null;
123127
if (System.getSecurityManager() != null) {
124128
i = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
@@ -130,7 +134,9 @@ public InputStream run() {
130134
} else {
131135
i = root.getResourceAsStream(resourceName);
132136
}
137+
*/
133138

139+
InputStream i = root.getResourceAsStream(resourceName);
134140
if (i == null && required) {
135141
throw new MissingResourceException("could not locate data " +resourceName, root.getPackage().getName(), resourceName);
136142
}
@@ -142,6 +148,7 @@ public InputStream run() {
142148
* Should be called only from ICUBinary.getData() or from convenience overloads here.
143149
*/
144150
static InputStream getStream(final ClassLoader loader, final String resourceName, boolean required) {
151+
/* SecurityManager is not supported on j2objc.
145152
InputStream i = null;
146153
if (System.getSecurityManager() != null) {
147154
i = AccessController.doPrivileged(new PrivilegedAction<InputStream>() {
@@ -152,7 +159,9 @@ public InputStream run() {
152159
});
153160
} else {
154161
i = loader.getResourceAsStream(resourceName);
155-
}
162+
}*/
163+
164+
InputStream i = loader.getResourceAsStream(resourceName);
156165
if (i == null && required) {
157166
throw new MissingResourceException("could not locate data", loader.toString(), resourceName);
158167
}

jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/util/ULocale.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4108,6 +4108,7 @@ public static boolean isOriginalDefaultLocale(Locale loc) {
41084108
}
41094109

41104110
public static String getSystemProperty(String key) {
4111+
/* SecurityManager is not supported on j2objc.
41114112
String val = null;
41124113
final String fkey = key;
41134114
if (System.getSecurityManager() != null) {
@@ -4125,6 +4126,8 @@ public String run() {
41254126
val = System.getProperty(fkey);
41264127
}
41274128
return val;
4129+
*/
4130+
return System.getProperty(key);
41284131
}
41294132
}
41304133
}

0 commit comments

Comments
 (0)