[Nice-commit] Nice/src/nice/tools/util SelfContainedClassLoader.java,NONE,1.1
Brought to you by:
bonniot
|
From: Daniel B. <bo...@us...> - 2005-04-12 13:57:42
|
Update of /cvsroot/nice/Nice/src/nice/tools/util In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10113/src/nice/tools/util Added Files: SelfContainedClassLoader.java Log Message: Run generated jars in a self-contained classloader, so that missing classes in the jar lead to errors, instead of being loaded from the parent. Use "classes" instead of nice.jar so that recent changes immediately affect testcases. Rethrow the cause exception when a testcase fails. --- NEW FILE: SelfContainedClassLoader.java --- /**************************************************************************/ /* N I C E */ /* A high-level object-oriented research language */ /* (c) Daniel Bonniot 2005 */ /* */ /* This program is free software; you can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License, or */ /* (at your option) any later version. */ /* */ /**************************************************************************/ package nice.tools.util; /** A class loader that does not delegate to any parent, except java* classes to the system classloader. @author Daniel Bonniot (bo...@us...) */ public class SelfContainedClassLoader extends java.net.URLClassLoader { public SelfContainedClassLoader(java.net.URL[] urls) { super(urls); } protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class res = this.findLoadedClass(name); if (res == null) try { res = this.findClass(name); } catch (ClassNotFoundException e) {} if (res == null && name.startsWith("java")) { res = ClassLoader.getSystemClassLoader().loadClass(name); } if (res == null) throw new ClassNotFoundException(name); if (resolve) this.resolveClass(res); return res; } } |