src/share/classes/java/net/URLClassLoader.java

Print this page
rev 10449 : 8046070: Class Data Sharing clean up and refactoring
Summary: Cleaned up CDS to be more configurable, maintainable and extensible
Reviewed-by: dholmes, coleenp, acorn, mchung

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2014, 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

@@ -405,23 +405,14 @@
             }
         }
         return pkg;
     }
 
-    /*
-     * Defines a Class using the class bytes obtained from the specified
-     * Resource. The resulting Class must be resolved before it can be
-     * used.
-     */
-    private Class<?> defineClass(String name, Resource res) throws IOException {
-        long t0 = System.nanoTime();
-        int i = name.lastIndexOf('.');
-        URL url = res.getCodeSourceURL();
-        if (i != -1) {
-            String pkgname = name.substring(0, i);
-            // Check if package already loaded.
-            Manifest man = res.getManifest();
+    // Also called by VM to define Package for classes loaded from the CDS
+    // archive
+    private void definePackageInternal(String pkgname, Manifest man, URL url)
+    {
             if (getAndVerifyPackage(pkgname, man, url) == null) {
                 try {
                     if (man != null) {
                         definePackage(pkgname, man, url);
                     } else {

@@ -436,10 +427,26 @@
                                                  pkgname);
                     }
                 }
             }
         }
+
+    /*
+     * Defines a Class using the class bytes obtained from the specified
+     * Resource. The resulting Class must be resolved before it can be
+     * used.
+     */
+    private Class<?> defineClass(String name, Resource res) throws IOException {
+        long t0 = System.nanoTime();
+        int i = name.lastIndexOf('.');
+        URL url = res.getCodeSourceURL();
+        if (i != -1) {
+            String pkgname = name.substring(0, i);
+            // Check if package already loaded.
+            Manifest man = res.getManifest();
+            definePackageInternal(pkgname, man, url);
+        }
         // Now read the class bytes and define the class
         java.nio.ByteBuffer bb = res.getByteBuffer();
         if (bb != null) {
             // Use (direct) ByteBuffer:
             CodeSigner[] signers = res.getCodeSigners();