|
From: Garcia, M. <mg...@Bu...> - 2001-05-07 15:49:37
|
Hi Kenny, you can write you own custom class loader if you have requirements that the primordial (system) class loader won't give you or if you need to load your classes from some other source. The system (core classes) files are always loaded first and anything else gets loaded off the classpath as needed. From what Finn was saying though, it seemslike Jython already has a custom class loader. The Class.forName() loads the named class (if not already loaded) into the Java interpreter and returns a Class object for it. If you want to check for a loaded Jython class I suggest trying the getName() method which returns a string. I dug up this URL that might help you get started, http://www.javaworld.com/javaworld/javatips/jw-javatip39.html later - Mick -----Original Message----- From: Kenny Leung To: jyt...@li... Sent: 5/7/01 12:56 AM Subject: Re: [Jython-dev] Why do python classes show up in Java under weird names? On Friday, May 4, 2001, at 11:05 AM, Finn Bock wrote: > Please keep in mind that getting the class name right is just one part > of the problem. The proxy classes are loaded by a custom classloader > (some instance of BytecodeLoader). By default, I doubt that the > Class.forName() call used by the framework will find the classes loaded > by the BytecodeLoaders. If it is jython that loads the framework, I can > ways of ensuring that the framework can find the proxyclasses. Thanks for the answers, Finn. Yes, you're right. Further experimentation reveals that the class.forName call uses the "standard" class loader, whichever that one is. Here's the backtrace. java.lang.ClassNotFoundException: org.python.proxies.Main$Main$1 at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:297) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286) at java.lang.ClassLoader.loadClass(ClassLoader.java:253) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:120) The documentation is sketchy on this front, but there seems to be no way to replace this standard class loader, nor is there a way to tell it that the class is already loaded in the system. (I assume it has been loaded into the system, because the code from this class has alredy been run. I'm not sure if this is true since I don't know how the Jython internals work.) If this is correct, Java is pretty broken. Even though a class has already been loaded in the system, there's no way to tell other parts of the system! -Kenny _______________________________________________ Jython-dev mailing list Jyt...@li... http://lists.sourceforge.net/lists/listinfo/jython-dev |