Track introduction of NoPreloadHolder.
Change-Id: Id8e3ff4af83820edfc36a88eb5e70de13df36030
diff --git a/ojluni/src/main/java/java/io/ObjectInputStream.java b/ojluni/src/main/java/java/io/ObjectInputStream.java
index 50f6374..d17f90d 100755
--- a/ojluni/src/main/java/java/io/ObjectInputStream.java
+++ b/ojluni/src/main/java/java/io/ObjectInputStream.java
@@ -2060,7 +2060,7 @@
* corresponding modifications to the above class.
*/
private static ClassLoader latestUserDefinedLoader() {
- return VMStack.getClosestUserClassLoader(bootstrapLoader, systemLoader);
+ return VMStack.getClosestUserClassLoader();
}
/**
diff --git a/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java b/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
index c6098d4..a040178 100755
--- a/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
+++ b/ojluni/src/main/java/javax/net/ssl/HttpsURLConnection.java
@@ -180,16 +180,26 @@
}
}
- /**
- * <code>HostnameVerifier</code> provides a callback mechanism so that
- * implementers of this interface can supply a policy for
- * handling the case where the host to connect to and
- * the server name from the certificate mismatch.
- * <p>
- * The default implementation will deny such connections.
+ /*
+ * Holds default instances so class preloading doesn't create an instance of
+ * it.
*/
- private static HostnameVerifier defaultHostnameVerifier =
- new DefaultHostnameVerifier();
+ private static class NoPreloadHolder {
+ public static HostnameVerifier defaultHostnameVerifier;
+ static {
+ try {
+ defaultHostnameVerifier = (HostnameVerifier)
+ Class.forName("com.android.okhttp.internal.tls.OkHostnameVerifier")
+ .getField("INSTANCE").get(null);
+ } catch (Exception e) {
+ throw new AssertionError("Failed to obtain okhttp HostnameVerifier", e);
+ }
+ }
+
+ public static SSLSocketFactory defaultSSLSocketFactory = (SSLSocketFactory) SSLSocketFactory
+ .getDefault();
+ }
+
/*
* The initial default <code>HostnameVerifier</code>. Should be
@@ -208,7 +218,7 @@
/**
* The <code>hostnameVerifier</code> for this object.
*/
- protected HostnameVerifier hostnameVerifier = defaultHostnameVerifier;
+ protected HostnameVerifier hostnameVerifier = NoPreloadHolder.defaultHostnameVerifier;
/**
* Sets the default <code>HostnameVerifier</code> inherited by a
@@ -236,7 +246,7 @@
if (sm != null) {
sm.checkPermission(new SSLPermission("setHostnameVerifier"));
}
- defaultHostnameVerifier = v;
+ NoPreloadHolder.defaultHostnameVerifier = v;
}
/**
@@ -247,12 +257,7 @@
* @see #setDefaultHostnameVerifier(HostnameVerifier)
*/
public static HostnameVerifier getDefaultHostnameVerifier() {
- return defaultHostnameVerifier;
- }
-
- /* @hide */
- public static boolean hasCustomDefaultHostnameVerifier() {
- return !(defaultHostnameVerifier instanceof DefaultHostnameVerifier);
+ return NoPreloadHolder.defaultHostnameVerifier;
}
/**