Here's the first iteration of cleanup for Main and CommandlineParser (with Marc's Kernel changes included). I didn't make any severe structural changes, which will take more work. However, I did:

- Make main() instantiate a Main instance, which now has appropriate instance vars
- Modify it to only System.exit when calling main() directly, as when running a script. Other cases will now want to catch MainExitException when calling Main.run(String[] args), if they should choose to capture exit status, cli arg errors, etc. In the case of Marc's RubyKernel mods, we're ok because it catches Throwable in the new MVM thread and ignores it.
- Modify main() to use System io streams, and all other cases of instantiating a Main instance to pass streams in. This should be a first step toward getting MVM to work with specified streams rather than automatically using System streams. We'll probably want to have these streams propagate into Ruby.java and start using them instead of System.in, out, and err where appropriate (like in IOHandlerUnseekable).

To do:

- general structural cleanup (big)
- additional cli args
- update usage message to include all we support

With this patch, everything passes all tests (including TestInvocation!), but there appears to be some rogue writes happening, perhaps because we don't System.exit in all cases anymore:

- ant test outputs usage info to System.out for some reason
- Rubicon's TestKernel spits out a couple numbers

I have not investigated those, and I'd like more eyes on this patch. I have not yet tried any of this with Rake.

On 4/6/06, Charles O Nutter <[EMAIL PROTECTED]> wrote:
Ugh. Main and CommandlineParser need some serious work for MVM to work correctly.

First, they use System.exit everywhere. Error in command line params? System.exit. Unknown argument? System.exit . Error during execution ( i.e. nonzero process result)? System.exit. Double-plus ungood.

Second, they use System streams by default; that's arguably fine if you're only ever running one JRuby instance in a VM, but it's obviously bad if you're trying to do MVM.

Third, Main had a bunch of class vars, including a CommandLine instance, which would totally kill launching MVMs in parallel.

Fourth, they're really tangled, messy code. They show their age.

I'm going to take a couple stabs at cleaning up and rewriting them so we can land the in-process script patch.

--
Charles Oliver Nutter @ headius.blogspot.com
JRuby Developer @ jruby.sourceforge.net
Application Architect @ www.ventera.com

Attachment: main_commandlineparser_cleanup_plus_inprocess_scripts.patch
Description: Binary data

Reply via email to