⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classloader.java

📁 this gcc-g++-3.3.1.tar.gz is a source file of gcc, you can learn more about gcc through this codes f
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
      {	Package[] parentPackages = parent.getPackages();	allPackages = new Package[parentPackages.length + packages.length];	System.arraycopy(parentPackages, 0, allPackages, 0,			 parentPackages.length);	System.arraycopy(packages, 0, allPackages, parentPackages.length,			 packages.length);      }    else      // XXX - Should we use the bootstrap classloader?      allPackages = packages;    return allPackages;  }  /**   * Called by <code>Runtime.loadLibrary()</code> to get an absolute path   * to a (system specific) library that was requested by a class loaded   * by this classloader. The default implementation returns   * <code>null</code>. It should be implemented by subclasses when they   * have a way to find the absolute path to a library. If this method   * returns null the library is searched for in the default locations   * (the directories listed in the <code>java.library.path</code> system   * property).   *   * @param name the (system specific) name of the requested library   * @return the full pathname to the requested library, or null   * @see Runtime#loadLibrary()   * @since 1.2   */  protected String findLibrary(String name)  {    return null;  }  /**    * Returns a class found in a system-specific way, typically   * via the <code>java.class.path</code> system property.  Loads the    * class if necessary.   *   * @param     name the class to resolve.   * @return    the class loaded.   * @exception java.lang.LinkageError    * @exception java.lang.ClassNotFoundException    */  protected final Class findSystemClass(String name)     throws java.lang.ClassNotFoundException  {    return gnu.gcj.runtime.VMClassLoader.instance.loadClass (name);  }  /**   * Helper to set the signers of a class. This should be called after   * defining the class.   *   * @param c the Class to set signers of   * @param signers the signers to set   * @since 1.1   */     protected final void setSigners(Class c, Object[] signers)  {    /*     * Does currently nothing. FIXME.     */   }  /**   * If a class named <code>name</code> was previously loaded using   * this <code>ClassLoader</code>, then it is returned.  Otherwise   * it returns <code>null</code>.   * @param     name  class to find.   * @return    the class loaded, or null.   */   protected final synchronized Class findLoadedClass(String name)  {    return (Class) loadedClasses.get(name);  }  /**   * Get a resource using the system classloader.   *   * @param name the name of the resource relative to the system classloader   * @return an input stream for the resource, or null   * @since 1.1   */  public static InputStream getSystemResourceAsStream(String name) {    return getSystemClassLoader().getResourceAsStream (name);  }  /**   * Get the URL to a resource using the system classloader.   *   * @param name the name of the resource relative to the system classloader   * @return the URL to the resource   * @since 1.1   */  public static URL getSystemResource(String name) {    return getSystemClassLoader().getResource (name);  }  /**   * Get an Enumeration of URLs to resources with a given name using the   * the system classloader. The enumeration firsts lists the resources with   * the given name that can be found by the bootstrap classloader followed   * by the resources with the given name that can be found on the classpath.   *   * @param name the name of the resource relative to the system classloader   * @return an Enumeration of URLs to the resources   * @throws IOException if I/O errors occur in the process   * @since 1.2   */  public static Enumeration getSystemResources(String name) throws IOException  {    return getSystemClassLoader().getResources(name);  }  /**   *   Return an InputStream representing the resource name.     *   This is essentially like    *   <code>getResource(name).openStream()</code>, except   *   it masks out any IOException and returns null on failure.   * @param   name  resource to load   * @return  an InputStream, or null   * @see     java.lang.ClassLoader#getResource(String)   * @see     java.io.InputStream   */  public InputStream getResourceAsStream(String name)   {    try      {	URL res = getResource (name);	if (res == null)          return null;	return res.openStream ();      }    catch (java.io.IOException x)      {	return null;      }  }   /**   * Return an java.io.URL representing the resouce <code>name</code>.     * The default implementation just returns <code>null</code>.   * @param   name  resource to load   * @return  a URL, or null if there is no such resource.   * @see     java.lang.ClassLoader#getResourceAsBytes(String)   * @see     java.lang.ClassLoader#getResourceAsStream(String)   * @see     java.io.URL   */  public URL getResource (String name)   {    // The rules say search the parent class if non-null,    // otherwise search the built-in class loader (assumed to be    // the system ClassLoader).  If not found, call    // findResource().    URL result = null;    ClassLoader delegate = parent;    if (delegate == null)      delegate = getSystemClassLoader ();	    // Protect ourselves from looping.    if (this != delegate)      result = delegate.getResource (name);    if (result != null)      return result;    else      return findResource (name);  }  /**   * Called whenever a resource is needed that could not be provided by   * one of the parents of this classloader. It is called by   * <code>getResource()</code> after <code>parent.getResource()</code>   * couldn't provide the requested resource.   *   * <p>The default implementation always returns null. Subclasses should   * override this method when they can provide a way to return a URL   * to a named resource.   *   * @param name the name of the resource to be found   * @return a URL to the named resource or null when not found   * @since 1.2   */  protected URL findResource (String name)  {    // Default to returning null.  Derived classes implement this.    return null;  }  /**   * Returns an Enumeration of all resources with a given name that can   * be found by this classloader and its parents. Certain classloaders   * (such as the URLClassLoader when given multiple jar files) can have   * multiple resources with the same name that come from multiple locations.   * It can also occur that a parent classloader offers a resource with a   * certain name and the child classloader also offers a resource with that   * same name. <code>getResource() only offers the first resource (of the   * parent) with a given name. This method lists all resources with the   * same name. The name should use '/' as path separators.   *   * <p>The Enumeration is created by first calling <code>getResources()</code>   * on the parent classloader and then calling <code>findResources()</code>   * on this classloader.   *   * @param name the resource name   * @return an enumaration of all resources found   * @throws IOException if I/O errors occur in the process   * @since 1.2   */  public final Enumeration getResources(String name) throws IOException  {    // The rules say search the parent class if non-null,    // otherwise search the built-in class loader (assumed to be    // the system ClassLoader).  If not found, call    // findResource().    Enumeration result = null;    ClassLoader delegate = parent;    if (delegate == null)      delegate = getSystemClassLoader ();	    // Protect ourselves from looping.    if (this != delegate)      result = delegate.getResources (name);    if (result != null)      return result;    else      return findResources (name);  }  /**   * Called whenever all locations of a named resource are needed.   * It is called by <code>getResources()</code> after it has called   * <code>parent.getResources()</code>. The results are combined by   * the <code>getResources()</code> method.   *   * <p>The default implementation always returns an empty Enumeration.   * Subclasses should override it when they can provide an Enumeration of   * URLs (possibly just one element) to the named resource.   * The first URL of the Enumeration should be the same as the one   * returned by <code>findResource</code>.   *   * @param name the name of the resource to be found   * @return a possibly empty Enumeration of URLs to the named resource   * @throws IOException if I/O errors occur in the process   * @since 1.2   */  protected Enumeration findResources(String name) throws IOException  {    return Collections.enumeration(Collections.EMPTY_LIST);  }  /**   * Set the default assertion status for classes loaded by this classloader,   * used unless overridden by a package or class request.   *   * @param enabled true to set the default to enabled   * @see #setClassAssertionStatus(String, boolean)   * @see #setPackageAssertionStatus(String, boolean)   * @see #clearAssertionStatus()   * @since 1.4   */  public void setDefaultAssertionStatus(boolean enabled)  {    defaultAssertionStatus = enabled;  }  /**   * Set the default assertion status for packages, used unless overridden   * by a class request. This default also covers subpackages, unless they   * are also specified. The unnamed package should use null for the name.   *   * @param name the package (and subpackages) to affect   * @param enabled true to set the default to enabled   * @see #setDefaultAssertionStatus(String, boolean)   * @see #setClassAssertionStatus(String, boolean)   * @see #clearAssertionStatus()   * @since 1.4   */  public synchronized void setPackageAssertionStatus(String name,                                                     boolean enabled)  {    if (packageAssertionStatus == null)      packageAssertionStatus        = new HashMap(systemPackageAssertionStatus);    packageAssertionStatus.put(name, Boolean.valueOf(enabled));  }    /**   * Set the default assertion status for a class. This only affects the   * status of top-level classes, any other string is harmless.   *   * @param name the class to affect   * @param enabled true to set the default to enabled   * @throws NullPointerException if name is null   * @see #setDefaultAssertionStatus(String, boolean)   * @see #setPackageAssertionStatus(String, boolean)   * @see #clearAssertionStatus()   * @since 1.4   */  public synchronized void setClassAssertionStatus(String name,                                                   boolean enabled)  {    if (classAssertionStatus == null)      classAssertionStatus = new HashMap(systemClassAssertionStatus);    // The toString() hack catches null, as required.    classAssertionStatus.put(name.toString(), Boolean.valueOf(enabled));  }    /**   * Resets the default assertion status of this classloader, its packages   * and classes, all to false. This allows overriding defaults inherited   * from the command line.   *   * @see #setDefaultAssertionStatus(boolean)   * @see #setClassAssertionStatus(String, boolean)   * @see #setPackageAssertionStatus(String, boolean)   * @since 1.4   */  public synchronized void clearAssertionStatus()  {    defaultAssertionStatus = false;    packageAssertionStatus = new HashMap();    classAssertionStatus = new HashMap();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -