7016707: Remove the BootClassLoaderHook for jkernel support
Reviewed-by: alanb, ohair
This commit is contained in:
parent
e0626b003a
commit
579f3ad056
@ -466,7 +466,6 @@ JAVA_JAVA_java = \
|
|||||||
java/security/ProtectionDomain.java \
|
java/security/ProtectionDomain.java \
|
||||||
java/net/URLClassLoader.java \
|
java/net/URLClassLoader.java \
|
||||||
java/net/URLConnection.java \
|
java/net/URLConnection.java \
|
||||||
sun/misc/BootClassLoaderHook.java \
|
|
||||||
sun/misc/Launcher.java \
|
sun/misc/Launcher.java \
|
||||||
sun/misc/MetaIndex.java \
|
sun/misc/MetaIndex.java \
|
||||||
sun/misc/URLClassPath.java \
|
sun/misc/URLClassPath.java \
|
||||||
|
@ -58,7 +58,6 @@ import java.util.StringTokenizer;
|
|||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
import sun.misc.BootClassLoaderHook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A representation of color profile data for device independent and
|
* A representation of color profile data for device independent and
|
||||||
@ -865,8 +864,7 @@ public class ICC_Profile implements Serializable {
|
|||||||
case ColorSpace.CS_PYCC:
|
case ColorSpace.CS_PYCC:
|
||||||
synchronized(ICC_Profile.class) {
|
synchronized(ICC_Profile.class) {
|
||||||
if (PYCCprofile == null) {
|
if (PYCCprofile == null) {
|
||||||
if (BootClassLoaderHook.getHook() != null ||
|
if (standardProfileExists("PYCC.pf"))
|
||||||
standardProfileExists("PYCC.pf"))
|
|
||||||
{
|
{
|
||||||
ProfileDeferralInfo pInfo =
|
ProfileDeferralInfo pInfo =
|
||||||
new ProfileDeferralInfo("PYCC.pf",
|
new ProfileDeferralInfo("PYCC.pf",
|
||||||
|
@ -51,7 +51,6 @@ import java.util.Vector;
|
|||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import sun.misc.BootClassLoaderHook;
|
|
||||||
import sun.misc.ClassFileTransformer;
|
import sun.misc.ClassFileTransformer;
|
||||||
import sun.misc.CompoundEnumeration;
|
import sun.misc.CompoundEnumeration;
|
||||||
import sun.misc.Resource;
|
import sun.misc.Resource;
|
||||||
@ -1300,7 +1299,6 @@ public abstract class ClassLoader {
|
|||||||
* Find resources from the VM's built-in classloader.
|
* Find resources from the VM's built-in classloader.
|
||||||
*/
|
*/
|
||||||
private static URL getBootstrapResource(String name) {
|
private static URL getBootstrapResource(String name) {
|
||||||
BootClassLoaderHook.preLoadResource(name);
|
|
||||||
URLClassPath ucp = getBootstrapClassPath();
|
URLClassPath ucp = getBootstrapClassPath();
|
||||||
Resource res = ucp.getResource(name);
|
Resource res = ucp.getResource(name);
|
||||||
return res != null ? res.getURL() : null;
|
return res != null ? res.getURL() : null;
|
||||||
@ -1814,7 +1812,6 @@ public abstract class ClassLoader {
|
|||||||
// Invoked in the java.lang.Runtime class to implement load and loadLibrary.
|
// Invoked in the java.lang.Runtime class to implement load and loadLibrary.
|
||||||
static void loadLibrary(Class fromClass, String name,
|
static void loadLibrary(Class fromClass, String name,
|
||||||
boolean isAbsolute) {
|
boolean isAbsolute) {
|
||||||
BootClassLoaderHook.preLoadLibrary(name);
|
|
||||||
ClassLoader loader =
|
ClassLoader loader =
|
||||||
(fromClass == null) ? null : fromClass.getClassLoader();
|
(fromClass == null) ? null : fromClass.getClassLoader();
|
||||||
if (sys_paths == null) {
|
if (sys_paths == null) {
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
package java.util.zip;
|
package java.util.zip;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import sun.misc.BootClassLoaderHook;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is used to represent a ZIP file entry.
|
* This class is used to represent a ZIP file entry.
|
||||||
|
@ -1,141 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009, 2010, 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.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URLStreamHandlerFactory;
|
|
||||||
import sun.misc.URLClassPath;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* BootClassLoaderHook defines an interface for a hook to inject
|
|
||||||
* into the bootstrap class loader.
|
|
||||||
*
|
|
||||||
* With jkernel now removed, no hook is set
|
|
||||||
*/
|
|
||||||
public abstract class BootClassLoaderHook {
|
|
||||||
private static BootClassLoaderHook bootLoaderHook = null;
|
|
||||||
public static synchronized BootClassLoaderHook getHook() {
|
|
||||||
return bootLoaderHook;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static synchronized void setHook(BootClassLoaderHook hook) {
|
|
||||||
if (!VM.isBooted()) {
|
|
||||||
throw new InternalError("hook can only be set after VM is booted");
|
|
||||||
}
|
|
||||||
if (bootLoaderHook != null) {
|
|
||||||
throw new InternalError("hook should not be reinitialized");
|
|
||||||
}
|
|
||||||
bootLoaderHook = hook;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BootClassLoaderHook() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to be invoked before a class loader loads
|
|
||||||
* a bootstrap class.
|
|
||||||
*
|
|
||||||
* @param classname the binary name of the class
|
|
||||||
*/
|
|
||||||
public static void preLoadClass(String classname) {
|
|
||||||
BootClassLoaderHook hook = getHook();
|
|
||||||
if (hook != null) {
|
|
||||||
hook.loadBootstrapClass(classname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to be invoked before a class loader loads
|
|
||||||
* a resource.
|
|
||||||
*
|
|
||||||
* @param resourcename the resource name
|
|
||||||
*/
|
|
||||||
public static void preLoadResource(String resourcename) {
|
|
||||||
BootClassLoaderHook hook = getHook();
|
|
||||||
if (hook != null) {
|
|
||||||
hook.getBootstrapResource(resourcename);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A method to be invoked before a library is loaded.
|
|
||||||
*
|
|
||||||
* @param libname the name of the library
|
|
||||||
*/
|
|
||||||
public static void preLoadLibrary(String libname) {
|
|
||||||
BootClassLoaderHook hook = getHook();
|
|
||||||
if (hook != null) {
|
|
||||||
hook.loadLibrary(libname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pathname of a JAR or class that the hook loads
|
|
||||||
* per this loadClass request; or null.
|
|
||||||
*
|
|
||||||
* @param classname the binary name of the class
|
|
||||||
*/
|
|
||||||
public abstract String loadBootstrapClass(String className);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a pathname of a resource file that the hook loads
|
|
||||||
* per this getResource request; or null.
|
|
||||||
*
|
|
||||||
* @param resourceName the resource name
|
|
||||||
*/
|
|
||||||
public abstract String getBootstrapResource(String resourceName);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the hook successfully performs an operation per
|
|
||||||
* this loadLibrary request; or false if it fails.
|
|
||||||
*
|
|
||||||
* @param libname the name of the library
|
|
||||||
*/
|
|
||||||
public abstract boolean loadLibrary(String libname);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a bootstrap class path constructed by the hook.
|
|
||||||
*
|
|
||||||
* @param bcp VM's bootstrap class path
|
|
||||||
* @param factory Launcher's URL stream handler
|
|
||||||
*/
|
|
||||||
public abstract URLClassPath getBootstrapClassPath(URLClassPath bcp,
|
|
||||||
URLStreamHandlerFactory factory);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the current thread is in the process of doing
|
|
||||||
* a prefetching operation.
|
|
||||||
*/
|
|
||||||
public abstract boolean isCurrentThreadPrefetching();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns true if the hook successfully prefetches the specified file.
|
|
||||||
*
|
|
||||||
* @param name a platform independent pathname
|
|
||||||
*/
|
|
||||||
public abstract boolean prefetchFile(String name);
|
|
||||||
}
|
|
@ -38,7 +38,6 @@ import java.util.StringTokenizer;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.AllPermission;
|
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.security.PrivilegedExceptionAction;
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.security.AccessControlContext;
|
import java.security.AccessControlContext;
|
||||||
@ -117,18 +116,6 @@ public class Launcher {
|
|||||||
return loader;
|
return loader;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addURLToAppClassLoader(URL u) {
|
|
||||||
AccessController.checkPermission(new AllPermission());
|
|
||||||
ClassLoader loader = Launcher.getLauncher().getClassLoader();
|
|
||||||
((Launcher.AppClassLoader) loader).addAppURL(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void addURLToExtClassLoader(URL u) {
|
|
||||||
AccessController.checkPermission(new AllPermission());
|
|
||||||
ClassLoader loader = Launcher.getLauncher().getClassLoader();
|
|
||||||
((Launcher.ExtClassLoader) loader.getParent()).addExtURL(u);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The class loader used for loading installed extensions.
|
* The class loader used for loading installed extensions.
|
||||||
*/
|
*/
|
||||||
@ -247,11 +234,6 @@ public class Launcher {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Class findClass(String name) throws ClassNotFoundException {
|
|
||||||
BootClassLoaderHook.preLoadClass(name);
|
|
||||||
return super.findClass(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AccessControlContext getContext(File[] dirs)
|
private static AccessControlContext getContext(File[] dirs)
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
@ -316,7 +298,6 @@ public class Launcher {
|
|||||||
public Class loadClass(String name, boolean resolve)
|
public Class loadClass(String name, boolean resolve)
|
||||||
throws ClassNotFoundException
|
throws ClassNotFoundException
|
||||||
{
|
{
|
||||||
BootClassLoaderHook.preLoadClass(name);
|
|
||||||
int i = name.lastIndexOf('.');
|
int i = name.lastIndexOf('.');
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
SecurityManager sm = System.getSecurityManager();
|
SecurityManager sm = System.getSecurityManager();
|
||||||
@ -373,10 +354,6 @@ public class Launcher {
|
|||||||
|
|
||||||
return acc;
|
return acc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addAppURL(URL url) {
|
|
||||||
super.addURL(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class BootClassPathHolder {
|
private static class BootClassPathHolder {
|
||||||
@ -413,11 +390,7 @@ public class Launcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static URLClassPath getBootstrapClassPath() {
|
public static URLClassPath getBootstrapClassPath() {
|
||||||
URLClassPath bcp = BootClassPathHolder.bcp;
|
return BootClassPathHolder.bcp;
|
||||||
// if DownloadManager is installed, return the bootstrap class path
|
|
||||||
// maintained by the Java kernel
|
|
||||||
BootClassLoaderHook hook = BootClassLoaderHook.getHook();
|
|
||||||
return hook == null ? bcp : hook.getBootstrapClassPath(bcp, factory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static URL[] pathToURLs(File[] path) {
|
private static URL[] pathToURLs(File[] path) {
|
||||||
|
@ -1,112 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2009, 2010, 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.
|
|
||||||
*
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.net.URLStreamHandlerFactory;
|
|
||||||
import sun.misc.BootClassLoaderHook;
|
|
||||||
import sun.misc.URLClassPath;
|
|
||||||
|
|
||||||
|
|
||||||
/* @test
|
|
||||||
* @bug 6888802
|
|
||||||
* @summary Sanity test of BootClassLoaderHook interface
|
|
||||||
*
|
|
||||||
* @build TestHook
|
|
||||||
* @run main TestHook
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class TestHook extends BootClassLoaderHook {
|
|
||||||
|
|
||||||
private static final TestHook hook = new TestHook();
|
|
||||||
private static Set<String> names = new TreeSet<String>();
|
|
||||||
private static final String LOGRECORD_CLASS =
|
|
||||||
"java.util.logging.LogRecord";
|
|
||||||
private static final String NONEXIST_RESOURCE =
|
|
||||||
"non.exist.resource";
|
|
||||||
private static final String LIBHELLO = "hello";
|
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
|
||||||
BootClassLoaderHook.setHook(hook);
|
|
||||||
if (BootClassLoaderHook.getHook() == null) {
|
|
||||||
throw new RuntimeException("Null boot classloader hook ");
|
|
||||||
}
|
|
||||||
|
|
||||||
testHook();
|
|
||||||
|
|
||||||
if (!names.contains(LOGRECORD_CLASS)) {
|
|
||||||
throw new RuntimeException("loadBootstrapClass for " + LOGRECORD_CLASS + " not called");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!names.contains(NONEXIST_RESOURCE)) {
|
|
||||||
throw new RuntimeException("getBootstrapResource for " + NONEXIST_RESOURCE + " not called");
|
|
||||||
}
|
|
||||||
if (!names.contains(LIBHELLO)) {
|
|
||||||
throw new RuntimeException("loadLibrary for " + LIBHELLO + " not called");
|
|
||||||
}
|
|
||||||
|
|
||||||
Set<String> copy = new TreeSet<String>();
|
|
||||||
copy.addAll(names);
|
|
||||||
for (String s : copy) {
|
|
||||||
System.out.println(" Loaded " + s);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void testHook() throws Exception {
|
|
||||||
Class.forName(LOGRECORD_CLASS);
|
|
||||||
ClassLoader.getSystemResource(NONEXIST_RESOURCE);
|
|
||||||
try {
|
|
||||||
System.loadLibrary(LIBHELLO);
|
|
||||||
} catch (UnsatisfiedLinkError e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String loadBootstrapClass(String className) {
|
|
||||||
names.add(className);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getBootstrapResource(String resourceName) {
|
|
||||||
names.add(resourceName);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean loadLibrary(String libname) {
|
|
||||||
names.add(libname);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public URLClassPath getBootstrapClassPath(URLClassPath bcp,
|
|
||||||
URLStreamHandlerFactory factory) {
|
|
||||||
return bcp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCurrentThreadPrefetching() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean prefetchFile(String name) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user