On Thu, Jun 25, 2009 at 4:04 AM, Craig Taverner<cr...@amanzi.com> wrote:
> Thanks Nick,
>
> Your explanation certainly derails my previous 'theory' :-(
>
>> We're working with pathnames here, not contents, so we don't actually go
>> so far as to open the URL or get its contents, so I'm not sure that what
>> you're describing will actually work. I'd consider it an enhancement at this
>> point to make something like
>> "IO.readlines('bundleresource://9/./some_script.rb')" actually do what you
>> expect (though note that this isn't the same problem that the OP mentioned).
>
> I guess IO.readlines() expects a filepath, not a url spec. I wonder if a
> hack like providing an alternative implementation of IO.readlines() that
> will consider the parameter as a url spec will work? That should have no
> change to JRuby code, and only requires that we take the (dangerous?)
> approach of adding an alternative IO impl in our deployment. (dangerous =
> risk of breaking the conformance to the RubySpec)

We've considered it. We may go in that direction, treating paths like
URLs where we can, either transparently or possibly activated by
requiring an additional JRuby-specific library (for precedent, see
Ruby's "open-uri" library). There are still common idioms in Ruby that
are still file-based that we can't easily generalize to URLs though
(e.g., "Dir[File.dirname(__FILE__) + '/submodules/*.rb].each {|f|
require f }").

>
>> Context classloader bugs in JRuby were fixed long ago, so I'm less suspect
>> of that being the problem.
>
> I'm sure you are right. However that does not rule out bugs in our plugins
> that create the JRuby. I think we still have to get our ducks in a row to
> make this work properly. I remember that last time I wrote JRuby startup
> code, I needed to set the context classloader in the current thread before
> starting the ruby runtime, otherwise none of the dependent plugins were
> visible to JRuby, so it seems there is stuff the developer needs to think
> about for this all to work.

If you can still find a case where this isn't working properly, let us
know. A search of JIRA shows a couple areas that have been fixed in
the past:

http://jira.codehaus.org/secure/IssueNavigator.jspa?reset=true&&query=classloader&summary=true&description=true&body=true&pid=11295

> Is there perhaps a wiki page or decent discussion on the JRuby Context
> classloader setup? I worked out the thread trick last year by reading JRuby
> code, but that does not mean I actually understood the details of what was
> going on. I think this is a tricky area and a decent writeup would be great.

This page has some information, and despite the mentions of 0.9.2
actually doesn't seem to be that out of date. It could use a refresh
though.

http://kenai.com/projects/jruby/pages/RequireAndLoadBehavior


> I'm actually quite happy to do that writeup myself, if I can get some
> pointers to the right information, even if that is just the relevant bits of
> code in JRuby to look through.

If you'd like to take on that task, I'd be happy to provide pointers!

Thanks,
/Nick

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

    http://xircles.codehaus.org/manage_email


Reply via email to