Skip to content

Use ByteBuffer#get(int index, byte[] dst) in Loader.java#3977

Merged
eregon merged 3 commits intoruby:mainfrom
eregon:ConstantPool-get-do-not-alter-position
Mar 9, 2026
Merged

Use ByteBuffer#get(int index, byte[] dst) in Loader.java#3977
eregon merged 3 commits intoruby:mainfrom
eregon:ConstantPool-get-do-not-alter-position

Conversation

@eregon
Copy link
Member

@eregon eregon commented Mar 8, 2026

  • This is an absolute bulk get which does not modify the position, and therefore saves from getting, setting and restoring the position.

From #3972 (comment)

* This is an absolute bulk get which does not modify the position,
  and therefore saves from getting, setting and restoring the position.
@eregon eregon marked this pull request as ready for review March 8, 2026 19:10
@eregon
Copy link
Member Author

eregon commented Mar 8, 2026

The CI passes even though that method doesn't exist on Java 8.
It's because it's using -target 1.8 -source 1.8 and that's not checking if JDK methods exist.
--release=8 (via ext.release = "8") does check it and find it:

javac --release=8 -Xlint -d tmp/java/prism -cp /home/eregon/.rubies/jruby-10.0.4.0/lib/jruby.jar java/org/ruby_lang/prism/AbstractNodeVisitor.java java/org/ruby_lang/prism/Loader.java java/org/ruby_lang/prism/MarkNewlinesVisitor.java java/org/ruby_lang/prism/Nodes.java java/org/ruby_lang/prism/ParseResult.java java/org/ruby_lang/prism/Parser.java java/org/ruby_lang/prism/ParsingOptions.java
warning: [options] source value 8 is obsolete and will be removed in a future release
warning: [options] target value 8 is obsolete and will be removed in a future release
warning: [options] To suppress warnings about obsolete options, use -Xlint:-options.
java/org/ruby_lang/prism/Loader.java:65: error: no suitable method found for get(int,byte[])
                buffer.get(start, bytes);
                      ^
    method ByteBuffer.get() is not applicable
      (actual and formal argument lists differ in length)
    method ByteBuffer.get(int) is not applicable
      (actual and formal argument lists differ in length)
    method ByteBuffer.get(byte[],int,int) is not applicable
      (actual and formal argument lists differ in length)
    method ByteBuffer.get(byte[]) is not applicable
      (actual and formal argument lists differ in length)
1 error
3 warnings

I think this is a good reason to update to JDK 21+ in Prism (which is what JRuby 10 requires).
I think JRuby 9 won't update to a newer Prism from latest master, isn't it? (especially now that Prism has release branches).
cc @headius @enebo

eregon added 2 commits March 8, 2026 20:13
* This is the minimum version that JRuby 10 requires.
* It's also the minimum version that TruffleRuby 33 requires.
@eregon eregon requested review from enebo and headius March 8, 2026 19:15
@eregon eregon merged commit c8fd89e into ruby:main Mar 9, 2026
67 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