Skip to content

Kernel#respond_to? fails if #respond_to_missing? is not defined #9258

@trinistr

Description

@trinistr

Environment Information

  • jruby 10.0.4.0-SNAPSHOT (3.4.5) 2026-02-22 ffffffffff OpenJDK 64-Bit Server VM 21.0.10+7 on 21.0.10+7 +indy +jit [x86_64-linux] (master)
  • Linux meow4 6.18.4-1-MANJARO #1 SMP PREEMPT_DYNAMIC Thu, 08 Jan 2026 12:46:08 +0000 x86_64 GNU/Linux

Expected Behavior

Given this file:

class A < BasicObject
  define_method(:respond_to?, ::Kernel.instance_method(:respond_to?))
end

puts A.new.respond_to?(:asdf) rescue nil

class B
  undef :respond_to_missing?
end

puts B.new.respond_to?(:asdf)

I expect:

false
false

Actual Behavior

NoMethodError: undefined method 'respond_to_missing?' for an instance of B
  respond_to? at org/jruby/RubyKernel.java:2223
       <main> at ./test.rb:11

(Note the rescue for A, that's why the error only happens for B, otherwise there is no difference.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions