[jsword-devel] ClassUtil and Java extension mechanism ClassNotFoundException

DM Smith dmsmith555 at yahoo.com
Thu May 8 10:27:05 MST 2008


Tonny Kohar wrote:
> Hi,
>
> Is it possible to change the implementation of
> Class.forName("SomeClass") in org.crosswire.common.util.ClassUtil  to
> from
> Class impl = Class.forName("some.package.SomeClass"); // replace this with
> ClassLoader cl = Thread.currentThread().getContextClassLoader(); // this
> Class c = cl.loadClass("some.module.Class");
>
> It is because Class.forName have various issues with Java extension
> mechanism and most often it will end up with ClassNotFoundException.
> For more detail regarding Class.forName problem, please look at this
> pdf http://www.javageeks.com/Papers/ClassForName/ClassForName.pdf
>
> Cheers
> Tonny Kohar
>   
Tonny,
You must be looking at 1.0.7 code. Current code does not have it.
We do call Class.forName in 23 places.

I've done the following:

Add to ClassUtil:

public static Class forName(String className)
{
  return 
Thread.currentThread().getContextClassLoader().loadClass(className);
}

And change all the
Class.forName(arg);
to
ClassUtil.forName(arg);

I'll check this in later today.

Thanks,
    DM Smith




More information about the jsword-devel mailing list