ClassLoader to use

Folks,

In the class JavaSupport, the following method uses the JRubyClassLoader
whose parent is the context classloader at the time of creation of
JRubyClassloader (say A). This seems restrictive. Now at some later
point, if I need to evaluate a script which references Java classes
available under a different classloader (say B), it does not work. The
change in comments helped.

public Class loadJavaClass(String className) {
try {
Class result = primitiveClass(className);
if(result == null) {
return (Ruby.isSecurityRestricted()) ?
Class.forName(className) :
Class.forName(className, true, javaClassLoader); //
javaClassLoader changed to
Thread.currentThread().getContextClassLoader()
}
return result;
} catch (ClassNotFoundException cnfExcptn) {
throw runtime.newNameError("cannot load Java class " +
className, className);
}
}

Does this look good? If so, should I file a bug for it to get included
in some patch? Else is there an API provided cleaner way of achieving
this? Please suggest!

thanks,
pankaj


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs