@Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { Handler.setUseFastConnectionExceptions(true); try { try { definePackageIfNecessary(name); } catch (IllegalArgumentException ex) { // Tolerate race condition due to being parallel capable if (getPackage(name) == null) { // This should never happen as the IllegalArgumentException indicates // that the package has already been defined and, therefore, // getPackage(name) should not return null. throw new AssertionError("Package " + name + " has already been " + "defined but it could not be found"); } } return super.loadClass(name, resolve); } finally { Handler.setUseFastConnectionExceptions(false); } }
/** * Attempt to load classes from the URLs before delegating to the parent loader. */ @Override protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException { synchronized (LaunchedURLClassLoader.LOCK_PROVIDER.getLock(this, name)) { Class<?> loadedClass = findLoadedClass(name); if (loadedClass == null) { Handler.setUseFastConnectionExceptions(true); try { loadedClass = doLoadClass(name); } finally { Handler.setUseFastConnectionExceptions(false); } } if (resolve) { resolveClass(loadedClass); } return loadedClass; } }
@Override public URL findResource(String name) { Handler.setUseFastConnectionExceptions(true); try { return super.findResource(name); } finally { Handler.setUseFastConnectionExceptions(false); } }
@Override public Enumeration<URL> findResources(String name) throws IOException { Handler.setUseFastConnectionExceptions(true); try { return super.findResources(name); } finally { Handler.setUseFastConnectionExceptions(false); } }
@Override public boolean hasMoreElements() { try { Handler.setUseFastConnectionExceptions(true); return this.rootResources.hasMoreElements() || this.localResources.hasMoreElements(); } finally { Handler.setUseFastConnectionExceptions(false); } }