src/share/classes/java/net/URLClassLoader.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File jdk Sdiff src/share/classes/java/net

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

Print this page


   1 /*
   2  * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 731         // Save the caller's context
 732         final AccessControlContext acc = AccessController.getContext();
 733         // Need a privileged block to create the class loader
 734         URLClassLoader ucl = AccessController.doPrivileged(
 735             new PrivilegedAction<URLClassLoader>() {
 736                 public URLClassLoader run() {
 737                     return new FactoryURLClassLoader(urls, acc);
 738                 }
 739             });
 740         return ucl;
 741     }
 742 
 743     static {
 744         sun.misc.SharedSecrets.setJavaNetAccess (
 745             new sun.misc.JavaNetAccess() {
 746                 public URLClassPath getURLClassPath (URLClassLoader u) {
 747                     return u.ucp;
 748                 }
 749             }
 750         );
 751         ClassLoader.registerAsParallelCapable();
 752     }
 753 }
 754 
 755 final class FactoryURLClassLoader extends URLClassLoader {
 756 
 757     static {
 758         ClassLoader.registerAsParallelCapable();
 759     }
 760 
 761     FactoryURLClassLoader(URL[] urls, ClassLoader parent,
 762                           AccessControlContext acc) {
 763         super(urls, parent, acc);
 764     }
 765 
 766     FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
 767         super(urls, acc);
 768     }
 769 
 770     public final Class<?> loadClass(String name, boolean resolve)
 771         throws ClassNotFoundException
 772     {
 773         // First check if we have permission to access the package. This
 774         // should go away once we've added support for exported packages.
 775         SecurityManager sm = System.getSecurityManager();
 776         if (sm != null) {
 777             int i = name.lastIndexOf('.');
 778             if (i != -1) {
   1 /*
   2  * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 731         // Save the caller's context
 732         final AccessControlContext acc = AccessController.getContext();
 733         // Need a privileged block to create the class loader
 734         URLClassLoader ucl = AccessController.doPrivileged(
 735             new PrivilegedAction<URLClassLoader>() {
 736                 public URLClassLoader run() {
 737                     return new FactoryURLClassLoader(urls, acc);
 738                 }
 739             });
 740         return ucl;
 741     }
 742 
 743     static {
 744         sun.misc.SharedSecrets.setJavaNetAccess (
 745             new sun.misc.JavaNetAccess() {
 746                 public URLClassPath getURLClassPath (URLClassLoader u) {
 747                     return u.ucp;
 748                 }
 749             }
 750         );
 751         ClassLoader.registerAsFullyConcurrent();
 752     }
 753 }
 754 
 755 final class FactoryURLClassLoader extends URLClassLoader {
 756 
 757     static {
 758         ClassLoader.registerAsFullyConcurrent();
 759     }
 760 
 761     FactoryURLClassLoader(URL[] urls, ClassLoader parent,
 762                           AccessControlContext acc) {
 763         super(urls, parent, acc);
 764     }
 765 
 766     FactoryURLClassLoader(URL[] urls, AccessControlContext acc) {
 767         super(urls, acc);
 768     }
 769 
 770     public final Class<?> loadClass(String name, boolean resolve)
 771         throws ClassNotFoundException
 772     {
 773         // First check if we have permission to access the package. This
 774         // should go away once we've added support for exported packages.
 775         SecurityManager sm = System.getSecurityManager();
 776         if (sm != null) {
 777             int i = name.lastIndexOf('.');
 778             if (i != -1) {
src/share/classes/java/net/URLClassLoader.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File