2 Jan 2009 01:47
Re: [groovy-user] RootLoader for system class?
Alexander Veit schrieb: >> Mike Dillon wrote: >> I understand that the "root ClassLoader" (system?) doesn't know about >> the Groovy lib directory. My point is that MBeanServerConnection is a >> class that is part of the JDK, regardless whether the mx4j >> JAR also has it. Groovy's classloader should be asking the system > classloader if it >> knows about MBeanServerConnection before it ever tries to >> load the class itself. On Java 5 and higher, this should result in the JDK > >> copy of the class being loaded in all cases, but it isn't. > > Oops, sorry. RootLoader indeed does strange things. loadClass(String, > boolean) effectively calls > > 1. findLoadedClass(String) > 2. findClass(String) > 3. super.loadClass(String, boolean) > > So 2. and 3. are in the wrong order since the loadClass call on the parent > loader should take place in the second step. I doubt that this is intent and > would suggest to file a bug report. before you goes start to try to find out that RootLoader does violate the typical class loading let me say that you are right and this is done on purpose. Even if the system class loader did respond to loading a class we cannot know if the loaded class is a system class or or for example simply in the endorsed directory or whatever. A simple example si the usage of commons-cli. We depend here on a certain version and there are other versions around. If now such a version somehow shows up in the system loader Groovy would probably not even start from command line anymore. If that wouldn't be needed RootLoader would not be needed too and it could be a normal URLClassLoader instead... maybe not even that. Of course this can have other side effects as well... for example APIs that are "suddenly" included in the jdk and where not before, but we did need them. You have this for MX, for XML and for other things probably too. And who knows what the future will bring here bye blackdrag -- -- Jochen "blackdrag" Theodorou The Groovy Project Tech Lead (http://groovy.codehaus.org) http://blackdragsview.blogspot.com/ --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email
RSS Feed