Some sun.misc internal APIs are deprectaed in JDK 9 and will be encapsulated or removed in a future release.
public CommonURLClassLoader(URL[] urls, ClassLoader parent) { super(urls, parent); this.urlClasspath = new URLClassPath(urls); }
protected Class<?> findClass(final String paramString) throws ClassNotFoundException { <...> String str = paramString.replace('.', '/').concat(".class"); Resource localResource = URLClassLoader.this.ucp.getResource(str, false); <...>
public void addURL(URL url) { urlClasspath.addURL(url); }
protected void rebuild() { try { sun.misc.URLClassPath cp = getURLClassPath((URLClassLoader) getCommonLoader()); URL[] urls = cp.getURLs(); if (urls.length < 1) return; StringBuffer path = new StringBuffer(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile())); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile())); path.append(s.getPath()); } System.setProperty("java.class.path", path.toString()); } catch (Exception e) { } }
private static Enumeration<URL> getBootstrapResources(String name) throws IOException { final Enumeration<Resource> e = getBootstrapClassPath().getResources(name); return new Enumeration<URL> () { public URL nextElement() { return e.nextElement().getURL(); } public boolean hasMoreElements() { return e.hasMoreElements(); } }; }
static public URL[] pathToURLs(String classpath) { return URLClassPath.pathToURLs(classpath); }
private void rebuildJavaClassPathVariable() throws Exception { sun.misc.URLClassPath cp = getURLClassPath(getSystemLoader()); URL[] urls = cp.getURLs(); if (urls.length < 1) return; StringBuffer path = new StringBuffer(urls.length * 32); File s = new File(URLDecoder.decode(urls[0].getFile())); path.append(s.getPath()); for (int i = 1; i < urls.length; i++) { path.append(File.pathSeparator); s = new File(URLDecoder.decode(urls[i].getFile())); path.append(s.getPath()); } try { System.setProperty("java.class.path", path.toString()); } catch (Exception e) { } } }
private static Enumeration<URL> getBootstrapResources(String name) throws IOException { final Enumeration<Resource> e = getBootstrapClassPath().getResources(name); return new Enumeration<URL> () { public URL nextElement() { return e.nextElement().getURL(); } public boolean hasMoreElements() { return e.hasMoreElements(); } }; }
private static Collection<String> getClasspathElements() { String classPath = System.getProperty("java.class.path"); URL[] classpathElements = URLClassPath.pathToURLs(classPath); Set<String> classPathItems = new HashSet<String>(); for (URL cpElem : classpathElements) { classPathItems.add(cpElem.getFile()); } return classPathItems; }
public CommonURLClassLoader(URL[] urls) { super(urls); this.urlClasspath = new URLClassPath(urls); }
public Object run() throws ClassNotFoundException { String path = name.replace('.', '/').concat(".class");//NOI18N //message("path=" + path); Resource res = ucp.getResource(path, false); if (res != null) { try { return defineClass(name, res); } catch (IOException e) { final String msg = ("Exception caught while loading class '"//NOI18N + name + "' : " + e);//NOI18N throw new ClassNotFoundException(msg, e); } } else { // ok if class resource not found (e.g. java.*) //throw new ClassNotFoundException(name); return null; } } }, acc);
public static ClazzLoader createBootstrapClassLoader() { URLClassPath cp = Launcher.getBootstrapClassPath(); return new UrlClazzLoader(BOOTSTRAP_CLASS_LOADER, "N/A", cp.getURLs()); } }
protected void addJarToPath(final URL jar, final URLClassLoader loader) throws Exception { this.getURLClassPath(loader).addURL(jar); }
public CommonURLClassLoader(URL[] urls, ClassLoader parent, URLStreamHandlerFactory factory) { super(urls, parent, factory); this.urlClasspath = new URLClassPath(urls); }
@Override public Resource getResource(String name) { Resource resource = super.getResource(name); if (resource == null) { return null; } if (name.endsWith(".class")) { return new MySafeAwareClassResource(name, resource, mySafeInstrumenter); } else { return resource; } }
public static ClazzLoader createBootstrapClassLoader() { URLClassPath cp = Launcher.getBootstrapClassPath(); return new UrlClazzLoader(BOOTSTRAP_CLASS_LOADER, "N/A", cp.getURLs()); } }
protected void addJarsToPath(final File dir, final URLClassLoader loader) throws Exception { if (dir == null || !dir.exists()) return; String[] jarNames = dir.list(new java.io.FilenameFilter() { public boolean accept(File dir, String name) { return (name.endsWith(".jar") || name.endsWith(".zip")); } }); final URL[] jars = new URL[jarNames.length]; for (int j = 0; j < jarNames.length; j++) { jars[j] = new File(dir, jarNames[j]).toURI().toURL(); } sun.misc.URLClassPath path = getURLClassPath(loader); for (int i = 0; i < jars.length; i++) { path.addURL(jars[i]); } }
/** * Creates a new EnhancerClassLoader for the specified url. * * @param urls the classpath to search */ protected EnhancerClassLoader(URL[] urls) { super(urls); acc = AccessController.getContext(); ucp = new URLClassPath(urls); checkUCP(urls); }
@Override public Resource getResource(String name, boolean check) { Resource resource = super.getResource(name, check); if (resource == null) { return null; } if (name.endsWith(".class")) { return new MySafeAwareClassResource(name, resource, mySafeInstrumenter); } else { return resource; } }
for( URL url : bootstrapClassPath.getURLs() )