/** * Finds and loads the class with the specified name from the search path. * * @throws ClassNotFoundException if the class is not found. */ @Override protected Class<?> findClass(final String name) throws ClassNotFoundException { try { final String path = name.replace('.', '/').concat(".class"); final Resource res = loadResource(path); if (res == null) { throw new ClassNotFoundException(name); } return defineClass(name, res); } catch (final IOException ioe) { throw new ClassNotFoundException(name, ioe); } }
/** * Finds and loads the class with the specified name from the search path. * * @throws ClassNotFoundException if the class is not found. */ @Override protected Class<?> findClass(final String name) throws ClassNotFoundException { try { final String path = name.replace('.', '/').concat(".class"); final Resource res = loadResource(path); if (res == null) { throw new ClassNotFoundException(name); } return defineClass(name, res); } catch (final IOException ioe) { throw new ClassNotFoundException(name, ioe); } }
/** * Finds and loads the class with the specified name from the search path. * * @throws ClassNotFoundException if the class is not found. */ @Override protected Class<?> findClass(final String name) throws ClassNotFoundException { try { final String path = name.replace('.', '/').concat(".class"); final Resource res = loadResource(path); if (res == null) { throw new ClassNotFoundException(name); } return defineClass(name, res); } catch (final IOException ioe) { throw new ClassNotFoundException(name, ioe); } }
/** * Loads and verifies the class with name and located with res. */ private Class<?> defineClass(final String name, final Resource res) throws IOException { final URL url = res.getCodeSourceURL(); final String pkgName = res.getPackageName(); if (pkgName != null) { final Package pkg = getPackage(pkgName); if (pkg != null) { if (pkg.isSealed()) { if (!pkg.isSealed(url)) { throw new FileSystemException("vfs.impl/pkg-sealed-other-url", pkgName); } } else { if (isSealed(res)) { throw new FileSystemException("vfs.impl/pkg-sealing-unsealed", pkgName); } } } else { definePackage(pkgName, res); } } final byte[] bytes = res.getBytes(); final Certificate[] certs = res.getFileObject().getContent().getCertificates(); final CodeSource cs = new CodeSource(url, certs); return defineClass(name, bytes, 0, bytes.length, cs); }
/** * Loads and verifies the class with name and located with res. */ private Class<?> defineClass(final String name, final Resource res) throws IOException { final URL url = res.getCodeSourceURL(); final String pkgName = res.getPackageName(); if (pkgName != null) { final Package pkg = getPackage(pkgName); if (pkg != null) { if (pkg.isSealed()) { if (!pkg.isSealed(url)) { throw new FileSystemException("vfs.impl/pkg-sealed-other-url", pkgName); } } else { if (isSealed(res)) { throw new FileSystemException("vfs.impl/pkg-sealing-unsealed", pkgName); } } } else { definePackage(pkgName, res); } } final byte[] bytes = res.getBytes(); final Certificate[] certs = res.getFileObject().getContent().getCertificates(); final CodeSource cs = new CodeSource(url, certs); return defineClass(name, bytes, 0, bytes.length, cs); }
/** * Loads and verifies the class with name and located with res. */ private Class<?> defineClass(final String name, final Resource res) throws IOException { final URL url = res.getCodeSourceURL(); final String pkgName = res.getPackageName(); if (pkgName != null) { final Package pkg = getPackage(pkgName); if (pkg != null) { if (pkg.isSealed()) { if (!pkg.isSealed(url)) { throw new FileSystemException("vfs.impl/pkg-sealed-other-url", pkgName); } } else { if (isSealed(res)) { throw new FileSystemException("vfs.impl/pkg-sealing-unsealed", pkgName); } } } else { definePackage(pkgName, res); } } final byte[] bytes = res.getBytes(); final Certificate[] certs = res.getFileObject().getContent().getCertificates(); final CodeSource cs = new CodeSource(url, certs); return defineClass(name, bytes, 0, bytes.length, cs); }