Repository navigation
Fix #295: Ignore Java package reference objects in JRuby - #403
Conversation
ccutrer
left a comment
There was a problem hiding this comment.
this won't work (for this particular use case):
irb(main):002:0> java.lang.respond_to?(:instance_methods)
=> true
jruby/jruby#7390 definitely will, though.
|
@ccutrer What version of jruby are you using? I get nil |
|
|
oh wait, duh, that's cause I have my .irbrc workaround in :). ignore me! |
|
Oh phew, I was about to check if you were the person who filed that issue as I just re-tested in 9.1, 9.2, 9.3, and 9.4-SNAPSHOT and got nil on all and was very confused |
|
Should we ignore them only JRuby? If It's yes, Can you add the condition of |
|
It's possible to create IRB-breaking objects on MRI & TruffleRuby too: module Weird
class << self
undef :instance_methods
end
endAs such, while JRuby had lots of them by default, I'm hesitant to add an engine check only for JRuby. If you think this isn't a concern though, I could add the check. 3.0.0 :001 > module Weird; class << self; undef :instance_methods; end; end
=> nil
3.0.0 :002 > ab./home/byteit101/.rvm/gems/ruby-3.0.0/gems/irb-1.4.2/lib/irb/completion.rb:354:in `block in retrieve_completion_data': undefined method `instance_methods' for Weird:Module (NoMethodError)
Did you mean? instance_method
from /home/byteit101/.rvm/gems/ruby-3.0.0/gems/irb-1.4.2/lib/irb/completion.rb:352:in `each_object'
from /home/byteit101/.rvm/gems/ruby-3.0.0/gems/irb-1.4.2/lib/irb/completion.rb:352:in `retrieve_completion_data'
from /home/byteit101/.rvm/gems/ruby-3.0.0/gems/irb-1.4.2/lib/irb/completion.rb:159:in `block in <module:InputCompletor>'
[snip...] |
|
This is moot now that we exclude our package modules from |
|
Well, I can still crash IRB on both JRuby and CRuby, so no this isn't moot. The most common case was taken care of yes, but I'd like to prevent IRB crashes |
|
I understand now: there's still an issue if you create - from Ruby code - a similar module that does not respond to the methods that IRB requires, and this affects any Ruby implementation running IRB. |
Ignore modules that don't have instance_methods on them. The same logic can be found in Pry to accommodate core JRuby features. Fixes #295