src/java.base/share/classes/java/lang/ClassLoader.java

Print this page


   1 /*
   2  * Copyright (c) 2013, 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


 939 
 940         return true;
 941     }
 942 
 943     /**
 944      * Links the specified class.  This (misleadingly named) method may be
 945      * used by a class loader to link a class.  If the class <tt>c</tt> has
 946      * already been linked, then this method simply returns. Otherwise, the
 947      * class is linked as described in the "Execution" chapter of
 948      * <cite>The Java&trade; Language Specification</cite>.
 949      *
 950      * @param  c
 951      *         The class to link
 952      *
 953      * @throws  NullPointerException
 954      *          If <tt>c</tt> is <tt>null</tt>.
 955      *
 956      * @see  #defineClass(String, byte[], int, int)
 957      */
 958     protected final void resolveClass(Class<?> c) {
 959         resolveClass0(c);


 960     }
 961 
 962     private native void resolveClass0(Class<?> c);
 963 
 964     /**
 965      * Finds a class with the specified <a href="#name">binary name</a>,
 966      * loading it if necessary.
 967      *
 968      * <p> This method loads the class through the system class loader (see
 969      * {@link #getSystemClassLoader()}).  The <tt>Class</tt> object returned
 970      * might have more than one <tt>ClassLoader</tt> associated with it.
 971      * Subclasses of <tt>ClassLoader</tt> need not usually invoke this method,
 972      * because most class loaders need to override just {@link
 973      * #findClass(String)}.  </p>
 974      *
 975      * @param  name
 976      *         The <a href="#name">binary name</a> of the class
 977      *
 978      * @return  The <tt>Class</tt> object for the specified <tt>name</tt>
 979      *
 980      * @throws  ClassNotFoundException
 981      *          If the class could not be found
 982      *


   1 /*
   2  * Copyright (c) 2013, 2014 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


 939 
 940         return true;
 941     }
 942 
 943     /**
 944      * Links the specified class.  This (misleadingly named) method may be
 945      * used by a class loader to link a class.  If the class <tt>c</tt> has
 946      * already been linked, then this method simply returns. Otherwise, the
 947      * class is linked as described in the "Execution" chapter of
 948      * <cite>The Java&trade; Language Specification</cite>.
 949      *
 950      * @param  c
 951      *         The class to link
 952      *
 953      * @throws  NullPointerException
 954      *          If <tt>c</tt> is <tt>null</tt>.
 955      *
 956      * @see  #defineClass(String, byte[], int, int)
 957      */
 958     protected final void resolveClass(Class<?> c) {
 959         if (c == null) {
 960             throw new NullPointerException();
 961         }
 962     }


 963 
 964     /**
 965      * Finds a class with the specified <a href="#name">binary name</a>,
 966      * loading it if necessary.
 967      *
 968      * <p> This method loads the class through the system class loader (see
 969      * {@link #getSystemClassLoader()}).  The <tt>Class</tt> object returned
 970      * might have more than one <tt>ClassLoader</tt> associated with it.
 971      * Subclasses of <tt>ClassLoader</tt> need not usually invoke this method,
 972      * because most class loaders need to override just {@link
 973      * #findClass(String)}.  </p>
 974      *
 975      * @param  name
 976      *         The <a href="#name">binary name</a> of the class
 977      *
 978      * @return  The <tt>Class</tt> object for the specified <tt>name</tt>
 979      *
 980      * @throws  ClassNotFoundException
 981      *          If the class could not be found
 982      *