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

Incorrect error class is rescued when the super class is Java::JavaLang::RuntimeException #4032

Closed
civitaspo opened this Issue Jul 27, 2016 · 2 comments

Comments

Projects
None yet
3 participants
@civitaspo

civitaspo commented Jul 27, 2016

Hello. I found a buggy behaviour about error handling. If the behaviour is expected, please close the issue.

Issue

  • Incorrect error class is rescued when the super class is Java::JavaLang::RuntimeException.

Sample Code

require 'java'

class MyError1 < Java::JavaLang::RuntimeException; end
class MyError2 < Java::JavaLang::RuntimeException; end

begin
  raise MyError1.new("my_error1")
rescue MyError2 => e
  puts "Why come here? error_class => #{e.class}, rescue MyError2."
  puts "e.kind_of?(MyError1) #=> #{e.kind_of?(MyError1)}"
  puts "e.kind_of?(MyError2) #=> #{e.kind_of?(MyError2)}"
end

The result is ...

Why come here? error_class => MyError1, rescue MyError2.
e.kind_of?(MyError1) #=> true
e.kind_of?(MyError2) #=> false

Environment

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc)
    • jruby 9.0.4.0 (2.2.2) 2015-11-12 b9fb7aa Java HotSpot(TM) 64-Bit Server VM 25.92-b14 on 1.8.0_92-b14 +jit [darwin-x86_64]
  • Operating system and platform (e.g. uname -a)
    • Darwin o-05796-mac.local 15.5.0 Darwin Kernel Version 15.5.0: Tue Apr 19 18:36:36 PDT 2016; root:xnu-3248.50.21~8/RELEASE_X86_64 x86_64

Expected Behavior

  • I think MyError1 should not be rescued.
@kares

This comment has been minimized.

Show comment
Hide comment
@kares

kares Aug 13, 2016

Member

this neither worked before (in JRuby 1.7) ... kind of a new feature for handling JI, not sure what it needs.

Member

kares commented Aug 13, 2016

this neither worked before (in JRuby 1.7) ... kind of a new feature for handling JI, not sure what it needs.

@kares kares closed this in 0ebd635 Aug 14, 2016

@civitaspo

This comment has been minimized.

Show comment
Hide comment
@civitaspo

civitaspo Aug 14, 2016

thanx so much!!

civitaspo commented Aug 14, 2016

thanx so much!!

@enebo enebo added this to the JRuby 9.1.3.0 milestone Aug 26, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment