So I thought I'd try to fix a few things. I'd really like someone to look over the autoload stuff here, as it *seems* to approximate what C ruby does, and it seems to work correctly now, but I don't have any extensive testcases for autoload right now.
With these fixes IRB execution dies while trying to access Binding, which is no surprise since Binding doesn't yet exist in JRuby. So now I have two apps that need binding to be working: Rails' generate script and IRB. Sigh. I think the world is trying to tell me something. Fix 1: Autoload added back in. I'm not sure if autoload was working before or got ripped out with the cref fixes or what, but this fix attempts to add it back in at the two major places where it shows up in C ruby: rb_const_get0 and ev_const_get, which map to our RubyModule#getConstantInner and ThreadContext.getConstant. Fix 2: As load paths are added to the internal array, normalize path seps to '/'. This may not be entirely safe, since I just do a replace of all \ with /...but hey, it's an improvement. Fix 3: Define a bogus undefine_finalizers method in ObjectSpace. This goes along with the current bogus define_finalizers. Huzzah! I guess I'm gonna have to bite the bullet and look at really implementing bindings. - Charlie On 2/9/06, Charles O Nutter <[EMAIL PROTECTED]> wrote: > Actually I spoke too soon...it appears we do have autoload capability, > but in this particular case it's not working...hmmm... > > On 2/9/06, Charles O Nutter <[EMAIL PROTECTED]> wrote: > > Thank you Wes, I will definitely have to take a look at that...it > > could be very helpful. You are correct in assuming there's no readline > > for Windows, however, so this may not get me where I want on my > > Windows machines. What does ruby use under Windows? I do see > > StdioInputMethod, so I thought I'd try running JRuby with IRB again. > > > > It turns out the current killer is the lack of autoload functionality > > in JRuby, which is an unfortunate lacking. Perhaps it's time we got > > around to adding it...I don't believe it would be *too* difficult. > > > > Thanks again, I'll have a look at your eval.rb on my *nix machines. > > > > - Charlie > > > > On 2/9/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > Here's a readline-enabled version of eval.rb that I've had lying around > > > for awhile. It's a modified version of eval.rb and doesn't require any > > > changes to jruby to run. It's not sophisticated at all; it's basically > > > eval.rb with readline's ability to do editing, history, etc. Since I > > > based the readline part on some java code, it has some java-isms in it > > > rather than doing things the ruby way. Any bugs should probably be > > > blamed on the original eval.rb. :) > > > > > > It's been tested on linux (I don't know if Win has a version of > > > libreadline-java). You need to have libreadline-java.jar on your > > > classpath and java also needs to be able to load libJavaReadline.so. So > > > this does not fulfill a pure java requirement, but it's been enough to > > > keep me from pulling my hair out. > > > > > > It handles both ruby exceptions and java ones. You can exit by hitting > > > C-d. > > > > > > The indenting is pretty unreliable (it's based on eval.rb) so I would > > > suggest setting it to 0. > > > > > > You can specify which readline library to load by editing the string at > > > the top of the file. You can use something other than GnuReadline > > > (Editline?) if that causes a licensing problem. > > > > > > If you put the file into lib/ruby/site_ruby, you can start it with a > > > shell script similar to this: > > > > > > #! /bin/sh > > > > > > export JAVA_HOME=/opt/java > > > export JRUBY_HOME=/opt/jruby/cvs/jruby > > > export READLINE=/usr/share/java/libreadline-java.jar > > > export CLASSPATH=$CLASSPATH:$READLINE:$JRUBY_HOME/lib/jruby.jar:. > > > > > > exec $JAVA_HOME/bin/java -classpath $CLASSPATH org.jruby.Main > > > -I$JRUBY_HOME/lib/ruby/site_ruby -reval_readline "$@" > > > > > > > > > > > > Wes > > > > > > On Thu, 9 Feb 2006, Charles O Nutter wrote: > > > > > > | It's become increasingly irritating that there's nothing equivalent to > > > | IRB that works with JRuby on the command-line. I'm personally tired of > > > | having a stack of test*.rb files around or using cumbersome -e strings > > > | to try out every little thing I need to test while working on JRuby. > > > | Something better is needed. > > > | > > > | Could Ruby's IRB be modified to work correctly with JRuby? I know it > > > | currently doesn't work because we don't have the terminal reading and > > > | manipulating capabilities necessary in Java, but could those > > > | requirements be ripped out? > > > | > > > | Is there an alternative to IRB that would work in JRuby? I'm not > > > | looking for anything fancy; just a basic interactive environment that > > > | I can run easily from the command-line. > > > | > > > | Could we just start working on our own simpler "jirb" so there's > > > | something roughly equivalent to IRB in the JRuby standard distro? > > > | How's this for a completely naive approach (that doesn't support > > > | multi-line constructs, naturally): > > > | > > > | STDOUT << '> ' > > > | > > > | while (x = > > > > > > -- > > > # Wes Nakamura <[EMAIL PROTECTED]> > > > > > > > > > > > > -- > > Charles Oliver Nutter @ headius.blogspot.com > > JRuby Developer @ jruby.sourceforge.net > > Application Architect @ www.ventera.com > > > > > -- > Charles Oliver Nutter @ headius.blogspot.com > JRuby Developer @ jruby.sourceforge.net > Application Architect @ www.ventera.com > -- Charles Oliver Nutter @ headius.blogspot.com JRuby Developer @ jruby.sourceforge.net Application Architect @ www.ventera.com
fixes_for_irb_20060209.patch
Description: Binary data
