Clone of #9491 for JRuby 10.1.
When executing this code:
class ClassB
def foo
code = eval( %Q{lambda { |*params|
for r in [1, 2, 3]
puts defined?(Array)
end
}
} )
self.define_singleton_method( :bar, &code )
self
end
end
ClassB.new.foo.bar(1, 2, 3)
the following error happens:
(eval):3:in `block in foo': is not a type/class (TypeError)
from org/jruby/RubyArray.java:2018:in `each'
from (eval):1:in `block in foo'
from (irb):62:in `evaluate'
from org/jruby/RubyKernel.java:1277:in `eval'
from org/jruby/RubyKernel.java:1725:in `loop'
from org/jruby/RubyKernel.java:1426:in `catch'
from /Users/gerhard/.rbenv/versions/jruby-9.4.14.0/lib/ruby/gems/shared/gems/irb-1.15.3/exe/irb:9:in `<main>'
from org/jruby/RubyKernel.java:1223:in `load'
from /Users/gerhard/.rbenv/versions/jruby-9.4.14.0/bin/irb:25:in `<main>'
Environment Information
Tested with Ruby 9.4.14.0 on Java 11.0.31:
JRUBY_VERSION
=> "9.4.14.0"
Java::java.lang.System.get_property("java.version")
=> "11.0.31"
Operating system:
uname -a
Darwin MacBook-Pro-7.local 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:42 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6031 arm64
Expected Behavior
When executing the Script with CRuby/MRI, I get the following:
ruby /tmp/script.rb
constant
constant
constant
Actual Behavior
Reactions are currently unavailable
Clone of #9491 for JRuby 10.1.
When executing this code:
the following error happens:
Environment Information
Tested with Ruby 9.4.14.0 on Java 11.0.31:
JRUBY_VERSION => "9.4.14.0" Java::java.lang.System.get_property("java.version") => "11.0.31"Operating system:
uname -a Darwin MacBook-Pro-7.local 25.5.0 Darwin Kernel Version 25.5.0: Mon Apr 27 20:39:42 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6031 arm64Expected Behavior
When executing the Script with CRuby/MRI, I get the following:
Actual Behavior