New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
$! not always being saved/restored in JRuby runtime when Ruby exceptions are handled #1601
Comments
I think with very few exceptions, if we're catching a RaiseException we should probably be clearing |
Reproduced an example using <=>: begin
0 <=> Time.now
rescue
puts "AAAA"
end
begin
raise
rescue
puts "C: #{$!}"
end |
Reopening so we can audit code and confirm everything is good. |
…g the raised exception
…bility semi-picked from 78e968e (jruby#1601)
* jruby-1_7: some more comparable asserts including for the Java compareTo part native RubySymbol#compareTo since we expect to always be able to sort should not-rewrite jump exceptions twice as well (not just raise ones) delete un-used imports [ji] do not rewrite stack-trace twice for Ruby (raise) exceptions base compareTo should not silence all Ruby raised exceptions (fixes #2232) re-arrange rescue spec (we're about to spec some more behavior) only test nil return from Object cmp on 1.9 (on 1.8.7 its expected to raise) more of correct $! restore + use get/setErrorInfo for better predictability another incorrect $! with numeric coercion on <=> + cleanup getRuntime() Fix some consumers for #1601. Don't leak out if we are swallowing the raised exception Conflicts: core/src/main/java/org/jruby/Main.java core/src/main/java/org/jruby/RubyBasicObject.java core/src/main/java/org/jruby/RubyClass.java core/src/main/java/org/jruby/RubyComparable.java core/src/main/java/org/jruby/RubyNumeric.java core/src/main/java/org/jruby/RubySymbol.java core/src/main/java/org/jruby/RubyTime.java core/src/main/java/org/jruby/javasupport/JavaCallable.java
has been open for 2+y ... just did a quick audit and all seems well. maybe the time has come to close? 😉 |
@kares 👍 |
Several classes in the JRuby runtime are catching Ruby exceptions. Those should save the old value of $! and restore them after the exception is handled. A quick grep revealed at the following files that need investigation and possible fixup. I've fixed up RubyFileTest.java in commit d10eade
[subbu@earth ir] grep -l 'catch (RaiseExcep' ../*
../Main.java
../RubyBasicObject.java
../RubyComparable.java
../RubyConverter.java
../RubyEnumerable.java
../RubyEnumerator.java
../RubyFile.java
../RubyFileTest.java
../RubyIO.java
../Ruby.java
../RubyKernel.java
../RubyNumeric.java
../RubyRange.java
../RubyRegexp.java
The text was updated successfully, but these errors were encountered: