Use Integer for JRuby VM messages#9499
Conversation
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.
|
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. |
|
@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.
|
@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. |
|
@lloeki Yes, please remove it. We expect new tests to only be run on fixed JRuby versions going forward. |
JRuby::VM#sendchecksFixnumwhen accepting integer messages. On JRuby 10 / Ruby 3.4 semantics,Fixnumis undefined, so sending integer messages raisesNameErrorbefore enqueuing.Use
Integerinstead. This keeps integer messages working on JRuby 10 and remains compatible with older supported JRuby versions.This fixes the sub-VM sample pattern:
Fixes #9498.
Testing
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"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"