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

Print this page




 254             return null;
 255         }
 256     }
 257 
 258    /**
 259     * Closes this URLClassLoader, so that it can no longer be used to load
 260     * new classes or resources that are defined by this loader.
 261     * Classes and resources defined by any of this loader's parents in the
 262     * delegation hierarchy are still accessible. Also, any classes or resources
 263     * that are already loaded, are still accessible.
 264     * <p>
 265     * In the case of jar: and file: URLs, it also closes any files
 266     * that were opened by it. If another thread is loading a
 267     * class when the {@code close} method is invoked, then the result of
 268     * that load is undefined.
 269     * <p>
 270     * The method makes a best effort attempt to close all opened files,
 271     * by catching {@link IOException}s internally. Unchecked exceptions
 272     * and errors are not caught. Calling close on an already closed
 273     * loader has no effect.
 274     * <p>
 275     * @exception IOException if closing any file opened by this class loader
 276     * resulted in an IOException. Any such exceptions are caught internally.
 277     * If only one is caught, then it is re-thrown. If more than one exception
 278     * is caught, then the second and following exceptions are added
 279     * as suppressed exceptions of the first one caught, which is then re-thrown.
 280     *
 281     * @exception SecurityException if a security manager is set, and it denies
 282     *   {@link RuntimePermission}{@code ("closeClassLoader")}
 283     *
 284     * @since 1.7
 285     */
 286     public void close() throws IOException {
 287         SecurityManager security = System.getSecurityManager();
 288         if (security != null) {
 289             security.checkPermission(new RuntimePermission("closeClassLoader"));
 290         }
 291         List<IOException> errors = ucp.closeLoaders();
 292 
 293         // now close any remaining streams.
 294 




 254             return null;
 255         }
 256     }
 257 
 258    /**
 259     * Closes this URLClassLoader, so that it can no longer be used to load
 260     * new classes or resources that are defined by this loader.
 261     * Classes and resources defined by any of this loader's parents in the
 262     * delegation hierarchy are still accessible. Also, any classes or resources
 263     * that are already loaded, are still accessible.
 264     * <p>
 265     * In the case of jar: and file: URLs, it also closes any files
 266     * that were opened by it. If another thread is loading a
 267     * class when the {@code close} method is invoked, then the result of
 268     * that load is undefined.
 269     * <p>
 270     * The method makes a best effort attempt to close all opened files,
 271     * by catching {@link IOException}s internally. Unchecked exceptions
 272     * and errors are not caught. Calling close on an already closed
 273     * loader has no effect.
 274     *
 275     * @exception IOException if closing any file opened by this class loader
 276     * resulted in an IOException. Any such exceptions are caught internally.
 277     * If only one is caught, then it is re-thrown. If more than one exception
 278     * is caught, then the second and following exceptions are added
 279     * as suppressed exceptions of the first one caught, which is then re-thrown.
 280     *
 281     * @exception SecurityException if a security manager is set, and it denies
 282     *   {@link RuntimePermission}{@code ("closeClassLoader")}
 283     *
 284     * @since 1.7
 285     */
 286     public void close() throws IOException {
 287         SecurityManager security = System.getSecurityManager();
 288         if (security != null) {
 289             security.checkPermission(new RuntimePermission("closeClassLoader"));
 290         }
 291         List<IOException> errors = ucp.closeLoaders();
 292 
 293         // now close any remaining streams.
 294