Once more into the breach! This patch should work with JRuby. Unfortunately I can't get "rvm jruby do rake test" to run since RubyKernel.java seems to be preferring its own version of rubygems but I tested the code itself in "rvm jruby irb".
"rake test" passes under MRI 1.9.3 and 1.8.7. Any other Ruby versions I need to worry about?
rework exception management for JRuby compatibility
This pull request passes (merged 6f87401 into 0d36b2f).