Skip to content

Commit c20e781

Browse files
tomballcopybara-github
authored andcommitted
Updates jre_emul build to set alwayslink=False on most libraries.
PiperOrigin-RevId: 607807793
1 parent 9659560 commit c20e781

File tree

5 files changed

+128
-142
lines changed

5 files changed

+128
-142
lines changed

jre_emul/android/platform/external/icu/android_icu4j/src/main/java/android/icu/text/TimeZoneNames.java

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
*/
1010
package android.icu.text;
1111

12-
import android.icu.impl.ICUConfig;
1312
import android.icu.impl.SoftCache;
1413
import android.icu.impl.TZDBTimeZoneNames;
1514
import android.icu.impl.TimeZoneNamesImpl;
@@ -117,35 +116,41 @@ public enum NameType {
117116

118117
private static Cache TZNAMES_CACHE = new Cache();
119118

120-
private static final Factory TZNAMES_FACTORY;
121-
private static final String FACTORY_NAME_PROP = "android.icu.text.TimeZoneNames.Factory.impl";
122-
private static final String DEFAULT_FACTORY_CLASS = "android.icu.impl.TimeZoneNamesFactoryImpl";
123-
124-
static {
125-
Factory factory = null;
126-
String classname = ICUConfig.get(FACTORY_NAME_PROP, DEFAULT_FACTORY_CLASS);
127-
while (true) {
128-
try {
129-
factory = (Factory) Class.forName(classname).newInstance();
130-
break;
131-
} catch (ClassNotFoundException cnfe) {
132-
// fall through
133-
} catch (IllegalAccessException iae) {
134-
// fall through
135-
} catch (InstantiationException ie) {
136-
// fall through
137-
}
138-
if (classname.equals(DEFAULT_FACTORY_CLASS)) {
139-
break;
140-
}
141-
classname = DEFAULT_FACTORY_CLASS;
142-
}
143-
144-
if (factory == null) {
145-
factory = new DefaultTimeZoneNames.FactoryImpl();
146-
}
147-
TZNAMES_FACTORY = factory;
148-
}
119+
// J2ObjC: always use default factory.
120+
// private static final Factory TZNAMES_FACTORY =
121+
// android.icu.impl.TimeZoneNamesFactoryImpl.class;
122+
// private static final Factory TZNAMES_FACTORY;
123+
// private static final String FACTORY_NAME_PROP =
124+
// "android.icu.text.TimeZoneNames.Factory.impl";
125+
// private static final String DEFAULT_FACTORY_CLASS =
126+
// "android.icu.impl.TimeZoneNamesFactoryImpl";
127+
128+
// static {
129+
// Factory factory = null;
130+
// String classname = ICUConfig.get(FACTORY_NAME_PROP, DEFAULT_FACTORY_CLASS);
131+
// while (true) {
132+
// try {
133+
// factory = (Factory) Class.forName(classname).newInstance();
134+
// break;
135+
// } catch (ClassNotFoundException cnfe) {
136+
// // fall through
137+
// } catch (IllegalAccessException iae) {
138+
// // fall through
139+
// } catch (InstantiationException ie) {
140+
// // fall through
141+
// }
142+
// if (classname.equals(DEFAULT_FACTORY_CLASS)) {
143+
// break;
144+
// }
145+
// classname = DEFAULT_FACTORY_CLASS;
146+
// }
147+
148+
// if (factory == null) {
149+
// factory = new DefaultTimeZoneNames.FactoryImpl();
150+
// }
151+
// TZNAMES_FACTORY = factory;
152+
// }
153+
private static final Factory TZNAMES_FACTORY = new android.icu.impl.TimeZoneNamesFactoryImpl();
149154

150155
/**
151156
* Returns an instance of <code>TimeZoneNames</code> for the specified locale.

jre_emul/android/platform/libcore/ojluni/src/main/java/java/net/NetworkInterface.java

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,14 @@
2525

2626
package java.net;
2727

28-
import android.system.ErrnoException;
28+
import static libcore.io.OsConstants.*;
2929

30-
import java.io.FileDescriptor;
31-
import java.util.ArrayList;
3230
import java.util.Arrays;
3331
import java.util.Collections;
3432
import java.util.Enumeration;
35-
import java.util.HashMap;
3633
import java.util.List;
37-
import java.util.Map;
3834
import java.util.NoSuchElementException;
3935

40-
import libcore.io.IoUtils;
41-
import libcore.io.Libcore;
42-
/* J2ObjC removed.
43-
import android.system.StructIfaddrs;
44-
import sun.security.action.*;
45-
import java.security.AccessController;
46-
*/
47-
48-
import static libcore.io.OsConstants.*;
49-
5036
// Android-note: NetworkInterface has been rewritten to avoid native code.
5137
// Fix upstream bug not returning link-down interfaces. http://b/26238832
5238
// Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849

jre_emul/android/platform/libcore/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@
2626

2727
package javax.net.ssl;
2828

29-
import java.net.URL;
30-
import com.google.j2objc.net.IosHttpsHandler;
3129
import java.net.HttpURLConnection;
30+
import java.net.URL;
3231
import java.security.Principal;
3332
import java.security.cert.X509Certificate;
3433
import javax.security.auth.x500.X500Principal;
@@ -458,9 +457,5 @@ public void setSSLSocketFactory(SSLSocketFactory sf) {
458457
*/
459458
public SSLSocketFactory getSSLSocketFactory() {
460459
return sslSocketFactory;
461-
}
462-
463-
// Create a compile-time link on the https stream handler, which is loaded dynamically by
464-
// URL.java.
465-
private static final Class<?> unused = IosHttpsHandler.class;
460+
}
466461
}

jre_emul/android/platform/libcore/ojluni/src/main/java/sun/nio/ch/DefaultAsynchronousChannelProvider.java

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
package sun.nio.ch;
2727

2828
import java.nio.channels.spi.AsynchronousChannelProvider;
29-
import java.security.AccessController;
30-
import sun.security.action.GetPropertyAction;
3129

3230
/**
3331
* Creates this platform's default asynchronous channel provider
@@ -40,41 +38,40 @@ public class DefaultAsynchronousChannelProvider {
4038
*/
4139
private DefaultAsynchronousChannelProvider() { }
4240

43-
@SuppressWarnings("unchecked")
44-
private static AsynchronousChannelProvider createProvider(String cn) {
45-
Class<AsynchronousChannelProvider> c;
46-
try {
47-
c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
48-
} catch (ClassNotFoundException x) {
49-
throw new AssertionError(x);
50-
}
51-
try {
52-
return c.newInstance();
53-
} catch (IllegalAccessException | InstantiationException x) {
54-
throw new AssertionError(x);
55-
}
41+
// J2ObjC-changed: unused
42+
// @SuppressWarnings("unchecked")
43+
// private static AsynchronousChannelProvider createProvider(String cn) {
44+
// Class<AsynchronousChannelProvider> c;
45+
// try {
46+
// c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
47+
// } catch (ClassNotFoundException x) {
48+
// throw new AssertionError(x);
49+
// }
50+
// try {
51+
// return c.newInstance();
52+
// } catch (IllegalAccessException | InstantiationException x) {
53+
// throw new AssertionError(x);
54+
// }
5655

57-
}
56+
// }
5857

59-
/**
60-
* Returns the default AsynchronousChannelProvider.
61-
*/
62-
public static AsynchronousChannelProvider create() {
63-
// BEGIN J2ObjC-changed: Hardcode AsynchronousChannelProvider provider.
64-
/*
65-
String osname = AccessController
66-
.doPrivileged(new GetPropertyAction("os.name"));
67-
if (osname.equals("SunOS"))
68-
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
69-
if (osname.equals("Linux"))
70-
return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
71-
if (osname.contains("OS X"))
72-
return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
73-
if (osname.equals("AIX"))
74-
return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
75-
throw new InternalError("platform not recognized");
76-
*/
58+
/** Returns the default AsynchronousChannelProvider. */
59+
public static AsynchronousChannelProvider create() {
60+
// BEGIN J2ObjC-changed: Hardcode AsynchronousChannelProvider provider.
61+
/*
62+
String osname = AccessController
63+
.doPrivileged(new GetPropertyAction("os.name"));
64+
if (osname.equals("SunOS"))
65+
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
66+
if (osname.equals("Linux"))
67+
return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
68+
if (osname.contains("OS X"))
7769
return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
70+
if (osname.equals("AIX"))
71+
return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
72+
throw new InternalError("platform not recognized");
73+
*/
74+
return new sun.nio.ch.BsdAsynchronousChannelProvider();
7875
// END Android-changed: Hardcode AsynchronousChannelProvider provider.
7976
}
8077
}

jre_emul/android/platform/libcore/xml/src/main/java/org/xmlpull/v1/XmlPullParserFactory.java

Lines changed: 59 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,19 @@ public class XmlPullParserFactory {
2929
// TODO: This can't be made final because it's a public API.
3030
protected HashMap<String, Boolean> features = new HashMap<String, Boolean>();
3131

32-
/**
33-
* Protected constructor to be called by factory implementations.
34-
*/
35-
protected XmlPullParserFactory() {
36-
parserClasses = new ArrayList<String>();
37-
serializerClasses = new ArrayList<String>();
38-
39-
try {
40-
parserClasses.add(Class.forName("org.kxml2.io.KXmlParser"));
41-
serializerClasses.add(Class.forName("org.kxml2.io.KXmlSerializer"));
42-
} catch (ClassNotFoundException e) {
43-
throw new AssertionError();
44-
}
45-
}
32+
/** Protected constructor to be called by factory implementations. */
33+
protected XmlPullParserFactory() {
34+
// J2ObjC: always use default classes.
35+
// parserClasses = new ArrayList<String>();
36+
// serializerClasses = new ArrayList<String>();
37+
38+
// try {
39+
// parserClasses.add(Class.forName("org.kxml2.io.KXmlParser"));
40+
// serializerClasses.add(Class.forName("org.kxml2.io.KXmlSerializer"));
41+
// } catch (ClassNotFoundException e) {
42+
// throw new AssertionError();
43+
// }
44+
}
4645

4746
/**
4847
* Set the features to be set when XML Pull Parser is created by this factory.
@@ -137,51 +136,55 @@ public XmlPullParser newPullParser() throws XmlPullParserException {
137136
}
138137

139138
private XmlPullParser getParserInstance() throws XmlPullParserException {
140-
ArrayList<Exception> exceptions = null;
141-
142-
if (parserClasses != null && !parserClasses.isEmpty()) {
143-
exceptions = new ArrayList<Exception>();
144-
for (Object o : parserClasses) {
145-
try {
146-
if (o != null) {
147-
Class<?> parserClass = (Class<?>) o;
148-
return (XmlPullParser) parserClass.newInstance();
149-
}
150-
} catch (InstantiationException e) {
151-
exceptions.add(e);
152-
} catch (IllegalAccessException e) {
153-
exceptions.add(e);
154-
} catch (ClassCastException e) {
155-
exceptions.add(e);
156-
}
157-
}
158-
}
159-
160-
throw newInstantiationException("Invalid parser class list", exceptions);
139+
// J2ObjC: always use default class.
140+
// ArrayList<Exception> exceptions = null;
141+
142+
// if (parserClasses != null && !parserClasses.isEmpty()) {
143+
// exceptions = new ArrayList<Exception>();
144+
// for (Object o : parserClasses) {
145+
// try {
146+
// if (o != null) {
147+
// Class<?> parserClass = (Class<?>) o;
148+
// return (XmlPullParser) parserClass.newInstance();
149+
// }
150+
// } catch (InstantiationException e) {
151+
// exceptions.add(e);
152+
// } catch (IllegalAccessException e) {
153+
// exceptions.add(e);
154+
// } catch (ClassCastException e) {
155+
// exceptions.add(e);
156+
// }
157+
// }
158+
// }
159+
160+
// throw newInstantiationException("Invalid parser class list", exceptions);
161+
return new org.kxml2.io.KXmlParser();
161162
}
162163

163164
private XmlSerializer getSerializerInstance() throws XmlPullParserException {
164-
ArrayList<Exception> exceptions = null;
165-
166-
if (serializerClasses != null && !serializerClasses.isEmpty()) {
167-
exceptions = new ArrayList<Exception>();
168-
for (Object o : serializerClasses) {
169-
try {
170-
if (o != null) {
171-
Class<?> serializerClass = (Class<?>) o;
172-
return (XmlSerializer) serializerClass.newInstance();
173-
}
174-
} catch (InstantiationException e) {
175-
exceptions.add(e);
176-
} catch (IllegalAccessException e) {
177-
exceptions.add(e);
178-
} catch (ClassCastException e) {
179-
exceptions.add(e);
180-
}
181-
}
182-
}
183-
184-
throw newInstantiationException("Invalid serializer class list", exceptions);
165+
// J2ObjC: always use default class.
166+
// ArrayList<Exception> exceptions = null;
167+
168+
// if (serializerClasses != null && !serializerClasses.isEmpty()) {
169+
// exceptions = new ArrayList<Exception>();
170+
// for (Object o : serializerClasses) {
171+
// try {
172+
// if (o != null) {
173+
// Class<?> serializerClass = (Class<?>) o;
174+
// return (XmlSerializer) serializerClass.newInstance();
175+
// }
176+
// } catch (InstantiationException e) {
177+
// exceptions.add(e);
178+
// } catch (IllegalAccessException e) {
179+
// exceptions.add(e);
180+
// } catch (ClassCastException e) {
181+
// exceptions.add(e);
182+
// }
183+
// }
184+
// }
185+
186+
// throw newInstantiationException("Invalid serializer class list", exceptions);
187+
return new org.kxml2.io.KXmlSerializer();
185188
}
186189

187190
private static XmlPullParserException newInstantiationException(String message,

0 commit comments

Comments
 (0)