ClassLoader (URL[] urls, ClassLoader parent) { return new URLClassLoader(urls, parent) { protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { SecurityManager sm = SecurityManager.current; if (sm != null) { int lastDot = name.lastIndexOf('.'); if (lastDot != -1) sm.checkPackageAccess(name.substring(0, lastDot)); } return super.loadClass(name, resolve); } }; }