protected Enumeration<URL> findResources(String name) throws IOException { return getParent().getResources( prefix+name); }
protected URL findResource(String name) { return getParent().getResource(prefix+name); }
@Override protected URL findResource(String name) { URL u = getParent().getResource(prefix + name); if (u != null) { try { jars.add(new JarFile(new File(toJarUrl(u).toURI()))); } catch (URISyntaxException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (IOException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (ClassNotFoundException ex) { //ignore - not a jar } } return u; }
@Override protected URL findResource(String name) { URL u = getParent().getResource(prefix + name); if (u != null) { try { jars.add(new JarFile(new File(toJarUrl(u).toURI()))); } catch (URISyntaxException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (IOException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (ClassNotFoundException ex) { //ignore - not a jar } } return u; }
@Override protected Enumeration<URL> findResources(String name) throws IOException { Enumeration<URL> en = getParent().getResources(prefix + name); while (en.hasMoreElements()) { try { jars.add(new JarFile(new File(toJarUrl(en.nextElement()).toURI()))); } catch (URISyntaxException ex) { //should not happen Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (IOException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (ClassNotFoundException ex) { //ignore - not a jar } } return en; }
@Override protected Enumeration<URL> findResources(String name) throws IOException { Enumeration<URL> en = getParent().getResources(prefix + name); while (en.hasMoreElements()) { try { jars.add(new JarFile(new File(toJarUrl(en.nextElement()).toURI()))); } catch (URISyntaxException ex) { //should not happen Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (IOException ex) { Logger.getLogger(ParallelWorldClassLoader.class.getName()).log(Level.WARNING, null, ex); } catch (ClassNotFoundException ex) { //ignore - not a jar } } return en; }
protected Class findClass(String name) throws ClassNotFoundException { StringBuffer sb = new StringBuffer(name.length()+prefix.length()+6); sb.append(prefix).append(name.replace('.','/')).append(".class"); InputStream is = getParent().getResourceAsStream(sb.toString()); if (is==null) throw new ClassNotFoundException(name); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[1024]; int len; while((len=is.read(buf))>=0) baos.write(buf,0,len); buf = baos.toByteArray(); int packIndex = name.lastIndexOf('.'); if (packIndex != -1) { String pkgname = name.substring(0, packIndex); // Check if package already loaded. Package pkg = getPackage(pkgname); if (pkg == null) { definePackage(pkgname, null, null, null, null, null, null, null); } } return defineClass(name,buf,0,buf.length); } catch (IOException e) { throw new ClassNotFoundException(name,e); } }
sb.append(prefix).append(name.replace('.','/')).append(".class"); URL u = getParent().getResource(sb.toString()); if (u == null) { throw new ClassNotFoundException(name);
sb.append(prefix).append(name.replace('.','/')).append(".class"); URL u = getParent().getResource(sb.toString()); if (u == null) { throw new ClassNotFoundException(name);