[kaffe] loadClass() vs. loadClass()
Helmer Krämer
hkraemer@freenet.de
Fri Sep 19 09:25:03 2003
On Fri, 19 Sep 2003 09:12:44 -0600 (MDT)
Timothy Stack <stack@cs.utah.edu> wrote:
Hi,
> > I gave JBoss another try recently and finally got to a
> > point where I really don't know what to do.
> >
> > As you will know, java.lang.ClassLoader contains two
> > different loadClass methods, one that takes a String
> > and a boolean as its parameters and one that takes
> > only a String. Whenever kaffe has to load some class
> > using a user defined loader, it invokes the two parameter
> > form of loadClass.
>
> Looks like this is just wrong, the javadoc says the single parameter one
> should be called...
I'll commit the change to classMethod.c, then.
> > JBOSS however contains a class loader that only overrides
> > the loadClass(String) method, but not the other one.
> > This means that it doesn't work with kaffe at the moment,
> > because some classes will not be found.
>
> Hmm, they should be overriding findClass(), is there any reason why they
> needed to use loadClass()?
Their class loader looks like this:
=======8<==================
public static Object create(final Class intf,
final ObjectName name,
final MBeanServer server)
{
// make a which delegates to MBeanProxyInstance's cl for it's class resolution
ClassLoader cl = new ClassLoader(intf.getClassLoader())
{
public Class loadClass(final String className) throws ClassNotFoundException
{
try {
return super.loadClass(className);
}
catch (ClassNotFoundException e) {
// only allow loading of MBeanProxyInstance from this loader
if (className.equals(MBeanProxyInstance.class.getName())) {
return MBeanProxyInstance.class.getClassLoader().loadClass(className);
}
// was some other classname, throw the CNFE
throw e;
}
}
};
return Proxy.newProxyInstance(cl,
new Class[] { MBeanProxyInstance.class, intf },
new MBeanProxyExt(name, server));
}
=======>8=================
So I think they could as well move the catch block
into a findClass() method.
Regards,
Helmer