From: David H. <dav...@gm...> - 2007-07-25 14:42:43
|
On 7/25/07, Charlie Groves <cha...@gm...> wrote: > I'm not quite following what you're saying here. What code throws a > ClassCastException? Is it Python code running in your interpreter > operating after the extraction? Oops, I meant ClassNotFoundException. I investigated further, and it happens that the code that runs before the extraction uses import, and the code that runs after the extraction uses Class.forName. import works both before and after extraction for the class in question. Class.forName throws ClassNotFoundException after extraction (don't know about before.) I assumed import and Class.forName should work the same when loading a Java class, but after a careful look I can't justify that assumption. The documentation for Class.forName(String className) states, "Invoking this method is equivalent to: Class.forName(className, true, currentLoader) where currentLoader denotes the defining class loader of the current class." It isn't clear what the correct Jython behavior should be in this case, since there isn't always a "current class" when executing Jython code (at least from the point of view of the Python code,) and in any case it isn't obvious what the "defining class loader" of a Jython class would be. Anyway, taking the difference between import and Class.forName into account, I don't believe that the extraction changed anything after all. The class in question is a jdbc driver, and using import followed by DriverManager.getConnection(url) results in "No suitable driver found." I don't know if that's expected or not, but I translated the code into Java (replacing import with Class.forName) and it works, so no worries. David |