Skip to content

Upgrade jruby#1092

Merged
myronmarston merged 5 commits intoblock:mainfrom
rossroberts-toast:upgrade_jruby
Mar 25, 2026
Merged

Upgrade jruby#1092
myronmarston merged 5 commits intoblock:mainfrom
rossroberts-toast:upgrade_jruby

Conversation

@rossroberts-toast
Copy link
Copy Markdown
Contributor

@rossroberts-toast rossroberts-toast commented Mar 24, 2026

  • Upgrades JRuby CI builds from jruby-10.0 to jruby-10.0.4.0 and setup-ruby from v1.288.0 to v1.295.0
  • Removes patch (Data.new splat forwarding) — fixed upstream in 10.0.4.0
  • Removes < 10.0.4.0 version gate so remaining patches stay active
  • Works around new JRuby 10.0.4.0 bug: include-ing a module in a Data.define block causes subclass fields to be nil. Fix defines instance methods directly in the block instead of via include InstanceMethods.

Upgrades JRuby CI builds from 10.0 to 10.0.4.0 and setup-ruby from
v1.288.0 to v1.295.0 across all workflow files.

JRuby patches updated for 10.0.4.0 compatibility:

- Remove the `< 10.0.4.0` version gate so patches remain active.
- Remove Bug 1 (Data.new splat forwarding) — fixed upstream in
  10.0.4.0 (jruby/jruby#9215, jruby/jruby#9225).
- Keep Bug 2 (Data#to_h/deconstruct on subclasses) — still needed,
  now applied via a Data.define hook since JRuby 10.0.4.0 defines
  to_h directly on each Data.define subclass.
- Work around a new JRuby 10.0.4.0 bug where `include`-ing a module
  in a Data.define block causes subclass instances to have nil fields
  in certain call patterns. Fix by defining instance methods directly
  in the Data.define block instead of using `include InstanceMethods`.
Copy link
Copy Markdown
Collaborator

@myronmarston myronmarston left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossroberts-toast
Copy link
Copy Markdown
Contributor Author

rossroberts-toast commented Mar 24, 2026

https://github.com/block/elasticgraph/blob/main/elasticgraph-schema_definition/lib/elastic_graph/schema_definition/jruby_patches.rb

regarding the patches in here:
9245 is still an active bug and isn't showing closed here so hopefully we see a patch for that in a later release: jruby/jruby#9245

9242, although closed, seems only partially fixed. I no longer see the ClassCastException but I can still trigger the spurious keyword argument warning:

#!/usr/bin/env ruby
# frozen_string_literal: true

# JRuby #9242: def initialize(...) + super(...) in a module prepended on a
# Struct subclass incorrectly warns about keyword arguments (3+ members)
# or crashes with ClassCastException (1 member).
#
# Run: ruby jruby_9242_struct_initialize.rb 2>&1

require "stringio"

puts "Ruby: #{RUBY_DESCRIPTION}"
puts

old_stderr = $stderr
$stderr = StringIO.new

mod = Module.new do
  def initialize(...)
    super(...)
  end
end

# Test 1: 3-member Struct (triggers spurious keyword warning)
puts "1. Struct with 3 members + prepended initialize(...):"
S3 = Struct.new(:a, :b, :c) { prepend mod }
obj3 = S3.new(1, 2, 3)
puts "   a=#{obj3.a} b=#{obj3.b} c=#{obj3.c}"
stderr_output = $stderr.string
$stderr = StringIO.new
if stderr_output.include?("keyword")
  puts "   FAIL: spurious warning: #{stderr_output.strip}"
else
  puts "   PASS: no spurious warning"
end
puts

# Test 2: 1-member Struct (used to crash with ClassCastException)
puts "2. Struct with 1 member + prepended initialize(...):"
begin
  S1 = Struct.new(:x) { prepend mod }
  obj1 = S1.new(1)
  stderr_output = $stderr.string
  $stderr = StringIO.new
  if stderr_output.include?("keyword")
    puts "   x=#{obj1.x}"
    puts "   FAIL: spurious warning: #{stderr_output.strip}"
  else
    puts "   x=#{obj1.x}"
    puts "   PASS: no crash, no warning"
  end
rescue => e
  puts "   FAIL: #{e.class}: #{e.message}"
end
puts

# Test 3: Same but with include instead of prepend
puts "3. Struct with 3 members + included initialize(...):"
$stderr = StringIO.new
S3i = Struct.new(:a, :b, :c) { include mod }
obj3i = S3i.new(1, 2, 3)
puts "   a=#{obj3i.a} b=#{obj3i.b} c=#{obj3i.c}"
stderr_output = $stderr.string
if stderr_output.include?("keyword")
  puts "   FAIL: spurious warning: #{stderr_output.strip}"
else
  puts "   PASS: no spurious warning"
end

$stderr = old_stderr

Here is the new issue i created reporting the bug only partially fixed: jruby/jruby#9328

@myronmarston myronmarston merged commit 0021ef8 into block:main Mar 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants