# HG changeset patch # User rriggs # Date 1438280218 14400 # Node ID 1f13aceb00d70037ff0869760b2eb5fe60adfed4 # Parent 7c00c692dd08b2e17553e287ab28d9c1e9be1f1e 8132705: Refactor SharedSecrets in sun.misc.JavaNetAccess Summary: Factor out access for InetAddress Reviewed-by: chegar, michaelm, alanb diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/java/net/InetAddress.java --- a/jdk/src/java.base/share/classes/java/net/InetAddress.java Thu Jul 30 08:46:21 2015 -0700 +++ b/jdk/src/java.base/share/classes/java/net/InetAddress.java Thu Jul 30 14:16:58 2015 -0400 @@ -297,6 +297,13 @@ return null; } }); + sun.misc.SharedSecrets.setJavaNetInetAddressAccess( + new sun.misc.JavaNetInetAddressAccess() { + public String getOriginalHostName(InetAddress ia) { + return ia.holder.getOriginalHostName(); + } + } + ); init(); } diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/java/net/URLClassLoader.java --- a/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Thu Jul 30 08:46:21 2015 -0700 +++ b/jdk/src/java.base/share/classes/java/net/URLClassLoader.java Thu Jul 30 14:16:58 2015 -0400 @@ -774,10 +774,6 @@ public URLClassPath getURLClassPath (URLClassLoader u) { return u.ucp; } - - public String getOriginalHostName(InetAddress ia) { - return ia.holder.getOriginalHostName(); - } } ); ClassLoader.registerAsParallelCapable(); diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/sun/misc/JavaNetAccess.java --- a/jdk/src/java.base/share/classes/sun/misc/JavaNetAccess.java Thu Jul 30 08:46:21 2015 -0700 +++ b/jdk/src/java.base/share/classes/sun/misc/JavaNetAccess.java Thu Jul 30 14:16:58 2015 -0400 @@ -26,17 +26,10 @@ package sun.misc; import java.net.URLClassLoader; -import java.net.InetAddress; public interface JavaNetAccess { /** * return the URLClassPath belonging to the given loader */ URLClassPath getURLClassPath (URLClassLoader u); - - /** - * Return the original application specified hostname of - * the given InetAddress object. - */ - String getOriginalHostName(InetAddress ia); } diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/sun/misc/JavaNetInetAddressAccess.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/classes/sun/misc/JavaNetInetAddressAccess.java Thu Jul 30 14:16:58 2015 -0400 @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package sun.misc; + +import java.net.InetAddress; + +public interface JavaNetInetAddressAccess { + /** + * Return the original application specified hostname of + * the given InetAddress object. + */ + String getOriginalHostName(InetAddress ia); +} diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/sun/misc/SharedSecrets.java --- a/jdk/src/java.base/share/classes/sun/misc/SharedSecrets.java Thu Jul 30 08:46:21 2015 -0700 +++ b/jdk/src/java.base/share/classes/sun/misc/SharedSecrets.java Thu Jul 30 14:16:58 2015 -0400 @@ -48,6 +48,7 @@ private static JavaLangRefAccess javaLangRefAccess; private static JavaIOAccess javaIOAccess; private static JavaNetAccess javaNetAccess; + private static JavaNetInetAddressAccess javaNetInetAddressAccess; private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; @@ -92,9 +93,19 @@ } public static JavaNetAccess getJavaNetAccess() { + if (javaNetAccess == null) + unsafe.ensureClassInitialized(java.net.URLClassLoader.class); return javaNetAccess; } + public static void setJavaNetInetAddressAccess(JavaNetInetAddressAccess jna) { + javaNetInetAddressAccess = jna; + } + + public static JavaNetInetAddressAccess getJavaNetInetAddressAccess() { + return javaNetInetAddressAccess; + } + public static void setJavaNetHttpCookieAccess(JavaNetHttpCookieAccess a) { javaNetHttpCookieAccess = a; } diff -r 7c00c692dd08 -r 1f13aceb00d7 jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Jul 30 08:46:21 2015 -0700 +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLSocketImpl.java Thu Jul 30 14:16:58 2015 -0400 @@ -42,7 +42,7 @@ import javax.net.ssl.*; import sun.misc.ManagedLocalsThread; -import sun.misc.JavaNetAccess; +import sun.misc.JavaNetInetAddressAccess; import sun.misc.SharedSecrets; /** @@ -2096,7 +2096,7 @@ /* * Get the original hostname via sun.misc.SharedSecrets. */ - JavaNetAccess jna = SharedSecrets.getJavaNetAccess(); + JavaNetInetAddressAccess jna = SharedSecrets.getJavaNetInetAddressAccess(); String originalHostname = jna.getOriginalHostName(inetAddress); /*