From: John G. <jgo...@co...> - 2001-11-08 21:54:32
|
Tried, still didn't help.. Of note: when I print the loader of ListBO from within Python, it says com.lutris.classloader.MultiClassLoader. When I print the loader of the superclass of ListBOFoo from within Java (that superclass is the same ListBO), it says sun.misc.Launcher$AppClassLoader! More and more puzzling. I feel that I'm SO CLOSE! Also: I'm now pulling the *class* from python to Java, not an instance of it. That seems to help, maybe... -- John Jeff Emanuel <je...@ad...> writes: > 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:I p > 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 > > > > > -- John Goerzen <jgo...@co...> GPG: 0x8A1D9A1F www.complete.org |