From: Finn B. <bc...@us...> - 2001-11-09 14:50:24
|
Update of /cvsroot/jython/bugtests In directory usw-pr-cvs1:/tmp/cvs-serv14656 Added Files: test338.py test338cl.java test338j.java test338j1.java test338m.py Log Message: Test for "[ #480017 ] Proxy supers are loaded from syspath". --- NEW FILE: test338.py --- """ [ #480017 ] Proxy supers are loaded from syspath """ import support support.compileJava("test338cl.java", classpath=".") support.compileJava("test338j1.java", classpath=".") support.compileJava("test338j.java", classpath=".") support.runJava("test338j", classpath=".") --- NEW FILE: test338cl.java --- import java.io.*; public class test338cl extends ClassLoader { protected Class loadClass(String name, boolean resolve) throws ClassNotFoundException { //System.out.println("MyLoadClass " + name); Class c = findLoadedClass(name); if (c != null) return c; try { FileInputStream fis = new FileInputStream(name.replace('.', '/') + ".class"); int size = fis.available(); byte[] buf = new byte[size]; fis.read(buf); fis.close(); c = defineClass(name, buf, 0, buf.length); if (resolve) resolveClass(c); return c; } catch (IOException exc) { return super.loadClass(name, resolve); } } } --- NEW FILE: test338j.java --- import org.python.util.*; import org.python.core.*; public class test338j implements Runnable { public static void main(String[] args) throws Exception { //new Main().run(); Runnable r = (Runnable)Class.forName("test338j", true, new test338cl()).newInstance(); r.run(); } public void run() { String brob = "test338m"; PythonInterpreter interp = new PythonInterpreter(); //Py.getSystemState().setClassLoader(this.getClass().getClassLoader()); interp.set("test338j1", test338j1.class); //interp.exec("mod = __import__('" + brob + "')"); interp.execfile(brob + ".py"); interp.exec("cl = " + brob + "()"); Object newobj = interp.get("cl", Object.class); //System.out.println(newobj.getClass().getClassLoader()); //System.out.println(newobj.getClass().getSuperclass().hashCode() + " " + test338j1.class.hashCode()); //System.out.println(newobj.getClass().getSuperclass().getClassLoader()); test338j1 boobj = (test338j1) newobj; //System.out.println(boobj.getDescription()); } } --- NEW FILE: test338j1.java --- public class test338j1 { public String getDescription() { return "a test338j1 description"; } } --- NEW FILE: test338m.py --- #import test338j1 class test338m(test338j1): def getDescription(self): desc = test338j1.getDescription(self) # Superclass call return "Foo_" + desc |