[jruby-user] it looks like a File named "classpath:/path" uses ByteList's classloaders. why?

0 views
Skip to first unread message

Najati Imam

unread,
Nov 16, 2010, 4:57:46 PM11/16/10
to JRuby Users
Hey All,

We're running our script inside a ScriptingContainer with a custom classloader that helps us find scripts in particular places. When trying to File.read a file with a name like "classpath:/path/to/file" we expected that classpath request to end up in the same classloader but, nay, it didn't. The stacktrace revealed the problem; to wit, the resource is being loaded using ByteList.EMPTY_BYTELIST.getClass().getClassLoader(). QQ This seems inconsistent. Is there a reason for not at least attempting to use the classloader set on the scripting container? Here's the line (ChannelDescriptor.java:660)

            InputStream is = ByteList.EMPTY_BYTELIST.getClass().getClassLoader().getResourceAsStream(path);

Thanks!
Najati

Yoko Harada

unread,
Nov 17, 2010, 1:29:58 PM11/17/10
to us...@jruby.codehaus.org
Hi,

Ah, so ChannelDescriptor.open method seems to need one more argument
for classloader. As far as I looked at related codes, the fix should
be easy. Would you file this to JIRA?

ScriptingContainer is new API for JRuby, and JRuby on custom
classloader is also new style. So, as you wrote, JRuby would have some
inconsistent implementations which has not yet revealed.

-Yoko

> Thanks!
> Najati

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


Najati Imam

unread,
Nov 17, 2010, 1:37:22 PM11/17/10
to us...@jruby.codehaus.org
Hi Yoko, thanks for responding!

I had actually already put together a hacked jruby doing just what you suggested but wasn't sure if it was good idea - I'm glad I wasn't too far off base. I'll put it up in JIRA with the patch when I have a moment - is there a preferred format for the patch?

Thanks!
Najati

Yoko Harada

unread,
Nov 17, 2010, 1:57:44 PM11/17/10
to us...@jruby.codehaus.org
On Wed, Nov 17, 2010 at 1:37 PM, Najati Imam <naj...@gmail.com> wrote:
> I had actually already put together a hacked jruby doing just what you
> suggested but wasn't sure if it was good idea - I'm glad I wasn't too far
> off base. I'll put it up in JIRA with the patch when I have a moment - is
> there a preferred format for the patch?

Git friendly patch would be nice since JRuby uses git.

-Yoko

Najati Imam

unread,
Nov 18, 2010, 8:43:13 AM11/18/10
to us...@jruby.codehaus.org
Submitted with patch here

Reply all
Reply to author
Forward
0 new messages