Skip to content

Commit

Permalink
Updates jre_emul build to set alwayslink=False on most libraries.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 607807793
  • Loading branch information
tomball authored and Copybara-Service committed Feb 16, 2024
1 parent 9659560 commit c20e781
Show file tree
Hide file tree
Showing 5 changed files with 128 additions and 142 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
*/
package android.icu.text;

import android.icu.impl.ICUConfig;
import android.icu.impl.SoftCache;
import android.icu.impl.TZDBTimeZoneNames;
import android.icu.impl.TimeZoneNamesImpl;
Expand Down Expand Up @@ -117,35 +116,41 @@ public enum NameType {

private static Cache TZNAMES_CACHE = new Cache();

private static final Factory TZNAMES_FACTORY;
private static final String FACTORY_NAME_PROP = "android.icu.text.TimeZoneNames.Factory.impl";
private static final String DEFAULT_FACTORY_CLASS = "android.icu.impl.TimeZoneNamesFactoryImpl";

static {
Factory factory = null;
String classname = ICUConfig.get(FACTORY_NAME_PROP, DEFAULT_FACTORY_CLASS);
while (true) {
try {
factory = (Factory) Class.forName(classname).newInstance();
break;
} catch (ClassNotFoundException cnfe) {
// fall through
} catch (IllegalAccessException iae) {
// fall through
} catch (InstantiationException ie) {
// fall through
}
if (classname.equals(DEFAULT_FACTORY_CLASS)) {
break;
}
classname = DEFAULT_FACTORY_CLASS;
}

if (factory == null) {
factory = new DefaultTimeZoneNames.FactoryImpl();
}
TZNAMES_FACTORY = factory;
}
// J2ObjC: always use default factory.
// private static final Factory TZNAMES_FACTORY =
// android.icu.impl.TimeZoneNamesFactoryImpl.class;
// private static final Factory TZNAMES_FACTORY;
// private static final String FACTORY_NAME_PROP =
// "android.icu.text.TimeZoneNames.Factory.impl";
// private static final String DEFAULT_FACTORY_CLASS =
// "android.icu.impl.TimeZoneNamesFactoryImpl";

// static {
// Factory factory = null;
// String classname = ICUConfig.get(FACTORY_NAME_PROP, DEFAULT_FACTORY_CLASS);
// while (true) {
// try {
// factory = (Factory) Class.forName(classname).newInstance();
// break;
// } catch (ClassNotFoundException cnfe) {
// // fall through
// } catch (IllegalAccessException iae) {
// // fall through
// } catch (InstantiationException ie) {
// // fall through
// }
// if (classname.equals(DEFAULT_FACTORY_CLASS)) {
// break;
// }
// classname = DEFAULT_FACTORY_CLASS;
// }

// if (factory == null) {
// factory = new DefaultTimeZoneNames.FactoryImpl();
// }
// TZNAMES_FACTORY = factory;
// }
private static final Factory TZNAMES_FACTORY = new android.icu.impl.TimeZoneNamesFactoryImpl();

/**
* Returns an instance of <code>TimeZoneNames</code> for the specified locale.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,14 @@

package java.net;

import android.system.ErrnoException;
import static libcore.io.OsConstants.*;

import java.io.FileDescriptor;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;

import libcore.io.IoUtils;
import libcore.io.Libcore;
/* J2ObjC removed.
import android.system.StructIfaddrs;
import sun.security.action.*;
import java.security.AccessController;
*/

import static libcore.io.OsConstants.*;

// Android-note: NetworkInterface has been rewritten to avoid native code.
// Fix upstream bug not returning link-down interfaces. http://b/26238832
// Android-added: Document restrictions for targetSdkVersion >= R. http://b/141455849
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@

package javax.net.ssl;

import java.net.URL;
import com.google.j2objc.net.IosHttpsHandler;
import java.net.HttpURLConnection;
import java.net.URL;
import java.security.Principal;
import java.security.cert.X509Certificate;
import javax.security.auth.x500.X500Principal;
Expand Down Expand Up @@ -458,9 +457,5 @@ public void setSSLSocketFactory(SSLSocketFactory sf) {
*/
public SSLSocketFactory getSSLSocketFactory() {
return sslSocketFactory;
}

// Create a compile-time link on the https stream handler, which is loaded dynamically by
// URL.java.
private static final Class<?> unused = IosHttpsHandler.class;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
package sun.nio.ch;

import java.nio.channels.spi.AsynchronousChannelProvider;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;

/**
* Creates this platform's default asynchronous channel provider
Expand All @@ -40,41 +38,40 @@ public class DefaultAsynchronousChannelProvider {
*/
private DefaultAsynchronousChannelProvider() { }

@SuppressWarnings("unchecked")
private static AsynchronousChannelProvider createProvider(String cn) {
Class<AsynchronousChannelProvider> c;
try {
c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
} catch (ClassNotFoundException x) {
throw new AssertionError(x);
}
try {
return c.newInstance();
} catch (IllegalAccessException | InstantiationException x) {
throw new AssertionError(x);
}
// J2ObjC-changed: unused
// @SuppressWarnings("unchecked")
// private static AsynchronousChannelProvider createProvider(String cn) {
// Class<AsynchronousChannelProvider> c;
// try {
// c = (Class<AsynchronousChannelProvider>)Class.forName(cn);
// } catch (ClassNotFoundException x) {
// throw new AssertionError(x);
// }
// try {
// return c.newInstance();
// } catch (IllegalAccessException | InstantiationException x) {
// throw new AssertionError(x);
// }

}
// }

/**
* Returns the default AsynchronousChannelProvider.
*/
public static AsynchronousChannelProvider create() {
// BEGIN J2ObjC-changed: Hardcode AsynchronousChannelProvider provider.
/*
String osname = AccessController
.doPrivileged(new GetPropertyAction("os.name"));
if (osname.equals("SunOS"))
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
if (osname.equals("Linux"))
return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
if (osname.contains("OS X"))
return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
if (osname.equals("AIX"))
return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
throw new InternalError("platform not recognized");
*/
/** Returns the default AsynchronousChannelProvider. */
public static AsynchronousChannelProvider create() {
// BEGIN J2ObjC-changed: Hardcode AsynchronousChannelProvider provider.
/*
String osname = AccessController
.doPrivileged(new GetPropertyAction("os.name"));
if (osname.equals("SunOS"))
return createProvider("sun.nio.ch.SolarisAsynchronousChannelProvider");
if (osname.equals("Linux"))
return createProvider("sun.nio.ch.LinuxAsynchronousChannelProvider");
if (osname.contains("OS X"))
return createProvider("sun.nio.ch.BsdAsynchronousChannelProvider");
if (osname.equals("AIX"))
return createProvider("sun.nio.ch.AixAsynchronousChannelProvider");
throw new InternalError("platform not recognized");
*/
return new sun.nio.ch.BsdAsynchronousChannelProvider();
// END Android-changed: Hardcode AsynchronousChannelProvider provider.
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,19 @@ public class XmlPullParserFactory {
// TODO: This can't be made final because it's a public API.
protected HashMap<String, Boolean> features = new HashMap<String, Boolean>();

/**
* Protected constructor to be called by factory implementations.
*/
protected XmlPullParserFactory() {
parserClasses = new ArrayList<String>();
serializerClasses = new ArrayList<String>();

try {
parserClasses.add(Class.forName("org.kxml2.io.KXmlParser"));
serializerClasses.add(Class.forName("org.kxml2.io.KXmlSerializer"));
} catch (ClassNotFoundException e) {
throw new AssertionError();
}
}
/** Protected constructor to be called by factory implementations. */
protected XmlPullParserFactory() {
// J2ObjC: always use default classes.
// parserClasses = new ArrayList<String>();
// serializerClasses = new ArrayList<String>();

// try {
// parserClasses.add(Class.forName("org.kxml2.io.KXmlParser"));
// serializerClasses.add(Class.forName("org.kxml2.io.KXmlSerializer"));
// } catch (ClassNotFoundException e) {
// throw new AssertionError();
// }
}

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

private XmlPullParser getParserInstance() throws XmlPullParserException {
ArrayList<Exception> exceptions = null;

if (parserClasses != null && !parserClasses.isEmpty()) {
exceptions = new ArrayList<Exception>();
for (Object o : parserClasses) {
try {
if (o != null) {
Class<?> parserClass = (Class<?>) o;
return (XmlPullParser) parserClass.newInstance();
}
} catch (InstantiationException e) {
exceptions.add(e);
} catch (IllegalAccessException e) {
exceptions.add(e);
} catch (ClassCastException e) {
exceptions.add(e);
}
}
}

throw newInstantiationException("Invalid parser class list", exceptions);
// J2ObjC: always use default class.
// ArrayList<Exception> exceptions = null;

// if (parserClasses != null && !parserClasses.isEmpty()) {
// exceptions = new ArrayList<Exception>();
// for (Object o : parserClasses) {
// try {
// if (o != null) {
// Class<?> parserClass = (Class<?>) o;
// return (XmlPullParser) parserClass.newInstance();
// }
// } catch (InstantiationException e) {
// exceptions.add(e);
// } catch (IllegalAccessException e) {
// exceptions.add(e);
// } catch (ClassCastException e) {
// exceptions.add(e);
// }
// }
// }

// throw newInstantiationException("Invalid parser class list", exceptions);
return new org.kxml2.io.KXmlParser();
}

private XmlSerializer getSerializerInstance() throws XmlPullParserException {
ArrayList<Exception> exceptions = null;

if (serializerClasses != null && !serializerClasses.isEmpty()) {
exceptions = new ArrayList<Exception>();
for (Object o : serializerClasses) {
try {
if (o != null) {
Class<?> serializerClass = (Class<?>) o;
return (XmlSerializer) serializerClass.newInstance();
}
} catch (InstantiationException e) {
exceptions.add(e);
} catch (IllegalAccessException e) {
exceptions.add(e);
} catch (ClassCastException e) {
exceptions.add(e);
}
}
}

throw newInstantiationException("Invalid serializer class list", exceptions);
// J2ObjC: always use default class.
// ArrayList<Exception> exceptions = null;

// if (serializerClasses != null && !serializerClasses.isEmpty()) {
// exceptions = new ArrayList<Exception>();
// for (Object o : serializerClasses) {
// try {
// if (o != null) {
// Class<?> serializerClass = (Class<?>) o;
// return (XmlSerializer) serializerClass.newInstance();
// }
// } catch (InstantiationException e) {
// exceptions.add(e);
// } catch (IllegalAccessException e) {
// exceptions.add(e);
// } catch (ClassCastException e) {
// exceptions.add(e);
// }
// }
// }

// throw newInstantiationException("Invalid serializer class list", exceptions);
return new org.kxml2.io.KXmlSerializer();
}

private static XmlPullParserException newInstantiationException(String message,
Expand Down

0 comments on commit c20e781

Please sign in to comment.