arton / rjb

Ruby Java Bridge
https://www.artonx.org/collabo/backyard/?RubyJavaBridge
GNU Lesser General Public License v2.1
117 stars 34 forks source link

respond_to? method of Exception object always returns true since rjb 1.5.9. #71

Closed buzztaiki closed 4 years ago

buzztaiki commented 5 years ago

I expect that respond_to? will return false when method does not exist. Standard object seems to be fine.

Test script:

require 'rjb'

def java_exception
  Rjb.import('java.lang.Integer').parseInt('XXX')
rescue StandardError => e
  e
else
  raise 'java exception not thrown'
end

puts Rjb::VERSION

puts Rjb.import('java.lang.String').new('XXX').respond_to? :unknown_method

e = java_exception
puts e.respond_to? :unknown_method
e.unknown_method if e.respond_to? :unknown_method

Results

rjb 1.6.0

1.6.0
false
true
Traceback (most recent call last):
        2: from test.rb:19:in `<main>'
        1: from test.rb:19:in `method_missing'
test.rb:19:in `method_missing': Fail: unknown method name `unknown_method' (RuntimeError)

rjb 1.5.9

bundle exec ruby test.rb
1.5.9
false
true
Traceback (most recent call last):
        2: from test.rb:19:in `<main>'
        1: from test.rb:19:in `method_missing'
test.rb:19:in `method_missing': Fail: unknown method name `unknown_method' (RuntimeError)

rjb 1.5.8

bundle exec ruby test.rb
1.5.8
false
false
arton commented 5 years ago

Hi Thank you for the report. Indeed I didn't implement respond_to? and 1.6.1 now fully supports it.

buzztaiki commented 5 years ago

Super fast! Thank you for your fix!

akiotajima commented 4 years ago

@buzztaiki Hi, would you please close this issue?

buzztaiki commented 4 years ago

Sorry, I forgot to close it.