Skip to content

Use Integer for JRuby VM messages#9499

Open
lloeki wants to merge 2 commits into
jruby:jruby-10.0from
lloeki:fix-jruby-vm-integer-messages
Open

Use Integer for JRuby VM messages#9499
lloeki wants to merge 2 commits into
jruby:jruby-10.0from
lloeki:fix-jruby-vm-integer-messages

Conversation

@lloeki

@lloeki lloeki commented Jun 18, 2026

Copy link
Copy Markdown

JRuby::VM#send checks Fixnum when accepting integer messages. On JRuby 10 / Ruby 3.4 semantics, Fixnum is undefined, so sending integer messages raises NameError before enqueuing.

Use Integer instead. This keeps integer messages working on JRuby 10 and remains compatible with older supported JRuby versions.

This fixes the sub-VM sample pattern:

vm << JRuby::VM_ID

Fixes #9498.

Testing

  • JRuby 10:
docker run --rm \
  -v /home/ll/src/github.com/jruby/jruby:/workspace \
  -w /workspace \
  ghcr.io/datadog/images-rb/engines/jruby:10.0 \
  jruby -I /workspace/lib/ruby/stdlib -rjruby/vm \
    -e "JRuby::VM.send_message(JRuby::VM_ID, 1); puts JRuby::VM.get_message"
  • JRuby 9.4:
docker run --rm \
  -v /home/ll/src/github.com/jruby/jruby:/workspace \
  -w /workspace \
  ghcr.io/datadog/images-rb/engines/jruby:9.4 \
  jruby -I /workspace/lib/ruby/stdlib -rjruby/vm \
    -e "JRuby::VM.send_message(JRuby::VM_ID, 1); puts JRuby::VM.get_message"

Ruby 3.4 no longer defines Fixnum, so sending integer messages through
jruby/vm fails before enqueuing on JRuby 10.

Check Integer instead, which also works on older supported versions and
keeps the sub-VM samples' VM id handoff working.
@lloeki

lloeki commented Jun 18, 2026

Copy link
Copy Markdown
Author

I could not find tests for sub-vm machinery, are these desirable to add in this PR?

If so I would appreciate guidance as to the best spot/approach to follow.

@kares kares added this to the JRuby 10.0.7.0 milestone Jun 19, 2026
@headius

headius commented Jul 8, 2026

Copy link
Copy Markdown
Member

@lloeki Tests would be very welcome! Clearly this needs more coverage. This utility library was largely created as a one-off experiment but I'd like to formalize it better with tests and documentation.

Since this does not seem like a time-critical fix for you perhaps we can add a few tests here and merge before the next release of 10.0.x?

Cover integer delivery through `JRuby::VM.send_message` and the
documented `vm << JRuby::VM_ID` child handoff. These paths failed on
JRuby 10 because `JRuby::VM#send` referenced the removed `Fixnum`
constant.

Include string delivery as a nearby sanity check and bound waits so a
broken child VM cannot hang the test suite.
@lloeki

lloeki commented Jul 17, 2026

Copy link
Copy Markdown
Author

@headius I've added some tests.

Note that there's a code path so that the test doesn't block when run against a JRuby version that doesn't carry the fix. LMK if you'd rather have that removed.

@headius

headius commented Jul 21, 2026

Copy link
Copy Markdown
Member

@lloeki Yes, please remove it. We expect new tests to only be run on fixed JRuby versions going forward.

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.

3 participants