changeset 3822:5dc98de2a35e

7016707: Remove the BootClassLoaderHook for jkernel support Reviewed-by: alanb, ohair
author mchung
date Fri, 25 Feb 2011 12:11:20 -0800
parents 32dc1cb2b995
children 8887cb2f5d19
files make/java/java/FILES_java.gmk src/share/classes/java/awt/color/ICC_Profile.java src/share/classes/java/lang/ClassLoader.java src/share/classes/java/util/zip/ZipEntry.java src/share/classes/sun/misc/BootClassLoaderHook.java src/share/classes/sun/misc/Launcher.java test/sun/misc/BootClassLoaderHook/TestHook.java
diffstat 7 files changed, 2 insertions(+), 289 deletions(-) [+]
line wrap: on
line diff
--- a/make/java/java/FILES_java.gmk	Fri Feb 25 11:42:11 2011 -0800
+++ b/make/java/java/FILES_java.gmk	Fri Feb 25 12:11:20 2011 -0800
@@ -466,7 +466,6 @@
     java/security/ProtectionDomain.java \
     java/net/URLClassLoader.java \
     java/net/URLConnection.java \
-    sun/misc/BootClassLoaderHook.java \
     sun/misc/Launcher.java \
     sun/misc/MetaIndex.java \
     sun/misc/URLClassPath.java \
--- a/src/share/classes/java/awt/color/ICC_Profile.java	Fri Feb 25 11:42:11 2011 -0800
+++ b/src/share/classes/java/awt/color/ICC_Profile.java	Fri Feb 25 12:11:20 2011 -0800
@@ -58,7 +58,6 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
-import sun.misc.BootClassLoaderHook;
 
 /**
  * A representation of color profile data for device independent and
@@ -865,8 +864,7 @@
         case ColorSpace.CS_PYCC:
             synchronized(ICC_Profile.class) {
                 if (PYCCprofile == null) {
-                    if (BootClassLoaderHook.getHook() != null ||
-                        standardProfileExists("PYCC.pf"))
+                    if (standardProfileExists("PYCC.pf"))
                     {
                         ProfileDeferralInfo pInfo =
                             new ProfileDeferralInfo("PYCC.pf",
--- a/src/share/classes/java/lang/ClassLoader.java	Fri Feb 25 11:42:11 2011 -0800
+++ b/src/share/classes/java/lang/ClassLoader.java	Fri Feb 25 12:11:20 2011 -0800
@@ -51,7 +51,6 @@
 import java.util.Hashtable;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
-import sun.misc.BootClassLoaderHook;
 import sun.misc.ClassFileTransformer;
 import sun.misc.CompoundEnumeration;
 import sun.misc.Resource;
@@ -1300,7 +1299,6 @@
      * Find resources from the VM's built-in classloader.
      */
     private static URL getBootstrapResource(String name) {
-        BootClassLoaderHook.preLoadResource(name);
         URLClassPath ucp = getBootstrapClassPath();
         Resource res = ucp.getResource(name);
         return res != null ? res.getURL() : null;
@@ -1814,7 +1812,6 @@
     // Invoked in the java.lang.Runtime class to implement load and loadLibrary.
     static void loadLibrary(Class fromClass, String name,
                             boolean isAbsolute) {
-        BootClassLoaderHook.preLoadLibrary(name);
         ClassLoader loader =
             (fromClass == null) ? null : fromClass.getClassLoader();
         if (sys_paths == null) {
--- a/src/share/classes/java/util/zip/ZipEntry.java	Fri Feb 25 11:42:11 2011 -0800
+++ b/src/share/classes/java/util/zip/ZipEntry.java	Fri Feb 25 12:11:20 2011 -0800
@@ -26,7 +26,6 @@
 package java.util.zip;
 
 import java.util.Date;
-import sun.misc.BootClassLoaderHook;
 
 /**
  * This class is used to represent a ZIP file entry.
--- a/src/share/classes/sun/misc/BootClassLoaderHook.java	Fri Feb 25 11:42:11 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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);
-}
--- a/src/share/classes/sun/misc/Launcher.java	Fri Feb 25 11:42:11 2011 -0800
+++ b/src/share/classes/sun/misc/Launcher.java	Fri Feb 25 12:11:20 2011 -0800
@@ -38,7 +38,6 @@
 import java.util.Set;
 import java.util.Vector;
 import java.security.AccessController;
-import java.security.AllPermission;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.security.AccessControlContext;
@@ -117,18 +116,6 @@
         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.
      */
@@ -247,11 +234,6 @@
             return null;
         }
 
-        protected Class findClass(String name) throws ClassNotFoundException {
-            BootClassLoaderHook.preLoadClass(name);
-            return super.findClass(name);
-        }
-
         private static AccessControlContext getContext(File[] dirs)
             throws IOException
         {
@@ -316,7 +298,6 @@
         public Class loadClass(String name, boolean resolve)
             throws ClassNotFoundException
         {
-            BootClassLoaderHook.preLoadClass(name);
             int i = name.lastIndexOf('.');
             if (i != -1) {
                 SecurityManager sm = System.getSecurityManager();
@@ -373,10 +354,6 @@
 
             return acc;
         }
-
-        void addAppURL(URL url) {
-            super.addURL(url);
-        }
     }
 
     private static class BootClassPathHolder {
@@ -413,11 +390,7 @@
     }
 
     public static URLClassPath getBootstrapClassPath() {
-        URLClassPath bcp = 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);
+        return BootClassPathHolder.bcp;
     }
 
     private static URL[] pathToURLs(File[] path) {
--- a/test/sun/misc/BootClassLoaderHook/TestHook.java	Fri Feb 25 11:42:11 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -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;
-    }
-}