Skip to content

Commit 5fa34ec

Browse files
yahondaryudoawaruiaddictclaude
committed
Work around ObjectSpace::WeakMap#values missing on older JRuby
JRuby before 9.3.0.0 does not define ObjectSpace::WeakMap#values natively (jruby/jruby#6267). Patch it using JRuby's field_reader to access the underlying Java map. Skip the patch when #values is already defined (JRuby 9.3.0.0 or higher via jruby/jruby#6683). Based on the approaches explored in rsim#2360 and rsim#2413, but guards with method_defined?(:values) instead of a version check so the workaround is skipped automatically once JRuby provides the method natively. Co-Authored-By: Ryudo Awaru <ryudoawaru@gmail.com> Co-Authored-By: Thomas Steinhausen <27787+iaddict@users.noreply.github.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent eade869 commit 5fa34ec

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/active_record/connection_adapters/oracle_enhanced_adapter.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -852,7 +852,8 @@ module ActiveRecord
852852
end
853853

854854
# Workaround for https://github.com/jruby/jruby/issues/6267
855-
if RUBY_ENGINE == "jruby"
855+
# Fixed in JRuby 9.3.0.0 or higher via https://github.com/jruby/jruby/pull/6683
856+
if RUBY_ENGINE == "jruby" && !ObjectSpace::WeakMap.method_defined?(:values)
856857
require "jruby"
857858

858859
class org.jruby::RubyObjectSpace::WeakMap

0 commit comments

Comments
 (0)