You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Kernel#inspect calls method_missing for instance_variables_to_inspect even when respond_to_missing? is false #10012
jruby 10.1.0.0 (4.0.0) 2026-04-20 32f988b78c OpenJDK 64-Bit Server VM 21.0.1 on 21.0.1 +indy +jit [arm64-darwin]
Also reproduced on GitHub Actions (ubuntu-latest) with jruby 10.1.2.0 (4.0.0) 2026-09-21 36cf8bbe87
As far as I can tell, 10.1.3.0 has the same code path (RubyBasicObject#hashyInspect uses Helpers.invokeChecked for instance_variables_to_inspect)
Expected Behavior
When an object doesn't define instance_variables_to_inspect, Kernel#inspect shouldn't send it through method_missing unless respond_to_missing? returns true. CRuby uses rb_check_funcall here, which checks respond_to_missing? before it calls method_missing:
JRuby calls method_missing(:instance_variables_to_inspect) and then raises because the return value isn't an Array:
$ jruby -v repro.rb
jruby 10.1.0.0 (4.0.0) 2026-04-20 32f988b78c OpenJDK 64-Bit Server VM 21.0.1 on 21.0.1 +indy +jit [arm64-darwin]
false
TypeError: Expected #instance_variables_to_inspect to return an Array or nil, but it returned Foo
inspect at org/jruby/RubyKernel.java:2286
<main> at repro.rb:12
Found via MiniMagick, where MiniMagick::Tool#method_missing turns any undefined method into a CLI option and returns self. Because of this, inspect fails on every MiniMagick::Tool instance on JRuby 10.1.
Activity