From: Jeff E. <je...@ad...> - 2001-11-08 21:40:52
|
I tried replicating what you are doing with a little stand-alone java program, but I can't seem to get the conversion to fail. Here's another hack you could try. Instead of passing the classloader to the script, pass the superclass. Java: interp.set("ListBO", this.getClass()); Python: # Omit import, ListBO is in namespace from above. class ListBOFoo(ListBO): # etc... John Goerzen wrote: > Jeff Emanuel <je...@ad...> writes: > > >>This seems a little more familiar since you are loading the java >>class with a custom class loader. When this has worked for me >>before, I have always used the system default class loader. >> > > Oddly enough, I didn't even realize that class loaders even existed > until your message yesterday, and certainly not that a non-default > loader was already being used. Alas, I fear that I have no control > over what loader is being used at the moment. > > >>Try finding the classloader for the superclass, as jython sees it. >>Something like this: >> > > I tried this, just from Python at the top of the module: > > print "Superclass loader: " + ListBO.getClassLoader().getClass().getName() > > Prior to your suggested hack below, this printed out > org.python.core.SyspathJavaLoader. > > >>I suspect that the jython super is not loaded by the same classloader and >> > > This is true... > > >>that is the root of your problems. I'm not sure if there is a way to >> > > ... but it doesn't seem to be the root of my problems. > > >>You might be able to set your custom classloader in the interpreter's >>name space and rewrite your scripts to use that. Something like this: >> > > [ snip ] > > I had to hack it to get the variable into the module, but I got it to > do that. > > >> ListBO=classloader.loadClass("quovix.business.util.ListBO") >> > > Now, the above print displays com.lutris.classloader.MultiClassLoader > -- the same as for my code in static Java. But -- I still get the > same ClassCastException in Java as before -- probably because the > ListBOFoo object is still being loaded by Python's loader (ByteLoader1). > > > -- John > > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users > |