[Nice-commit] Nice/src/bossa/syntax InlinedMethod.java,1.12,1.13
Brought to you by:
bonniot
From: <bo...@us...> - 2003-09-05 21:21:06
|
Update of /cvsroot/nice/Nice/src/bossa/syntax In directory sc8-pr-cvs1:/tmp/cvs-serv5403/src/bossa/syntax Modified Files: InlinedMethod.java Log Message: Allows to specify an alternate directory where inlined methods can be found. This is especially useful for bootstrap. Index: InlinedMethod.java =================================================================== RCS file: /cvsroot/nice/Nice/src/bossa/syntax/InlinedMethod.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** InlinedMethod.java 17 Jun 2003 12:03:05 -0000 1.12 --- InlinedMethod.java 5 Sep 2003 21:21:03 -0000 1.13 *************** *** 60,64 **** Class refClass = null; try{ ! refClass = Class.forName(inlineProcedure.toString()); } catch(ClassNotFoundException e){ --- 60,64 ---- Class refClass = null; try{ ! refClass = findClass(inlineProcedure.toString()); } catch(ClassNotFoundException e){ *************** *** 107,110 **** --- 107,164 ---- this.procedure = (gnu.mapping.Procedure) o; + } + + private Class findClass(String name) throws ClassNotFoundException + { + if (loader == null) + return Class.forName(name); + else + return loader.loadClass(name); + } + + static ClassLoader loader; + + static + { + String inlinedMethodsRepository = System.getProperty("nice.inlined"); + if (inlinedMethodsRepository != null) + try { + inlinedMethodsRepository = "file://" + + new java.io.File(inlinedMethodsRepository).getAbsolutePath() + '/'; + loader = new java.net.URLClassLoader + (new java.net.URL[]{ new java.net.URL(inlinedMethodsRepository) }) + { + protected Class loadClass(String name, boolean resolve) + throws ClassNotFoundException + { + /* Change the default behviour, which is to look up the + parent classloader first. Instead, look it up after this one, + so that the inlined methods are found here, but the + interfaces they implement are found in the system classloader, + so that the casts for using them succeed. + */ + Class res = findLoadedClass(name); + + if (res == null) + try { + res = this.findClass(name); + } + catch (ClassNotFoundException ex) {} + + if (res == null) + res = getParent().loadClass(name); + + if (resolve && res != null) + resolveClass(res); + + return res; + } + }; + } + catch (java.net.MalformedURLException ex) { + bossa.util.Internal.warning + ("Incorrect location for inlined methods: " + + inlinedMethodsRepository); + } } |