From fd4f0efedaa191a5a97169ad0862f31002b6226d Mon Sep 17 00:00:00 2001 From: ydah Date: Sun, 8 Jun 2025 18:23:23 +0900 Subject: [PATCH 1/2] Fix Java version mismatch errors We are trying to compile for Java 8 with `-target 1.8 -source 1.8 `at compile time but the JRuby jar file (jruby.jar) is compiled with Java 21 - Error message: `class file has wrong version 65.0, should be 61.0` - version 65.0 = Java 21 - version 61.0 = Java 17 --- Rakefile | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index f6fb3b8f..05a7e013 100644 --- a/Rakefile +++ b/Rakefile @@ -68,8 +68,15 @@ if jruby? lib_dir = ext.lib_dir += "/#{ext.platform}/racc" ext.ext_dir = 'ext/racc' # source/target jvm - ext.source_version = '1.8' - ext.target_version = '1.8' + if defined?(JRUBY_VERSION) && Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('10.0.0.0') + # Use Java 21 for JRuby 10.0.0.0 or higher + ext.source_version = '21' + ext.target_version = '21' + else + # Use Java 8 if its lower than JRuby 10.0.0.0 + ext.source_version = '1.8' + ext.target_version = '1.8' + end jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar'] ext.classpath = jars.map { |x| File.expand_path x }.join( ':' ) ext.name = 'cparse-jruby' From 2336833e73d8aae3bddf52922938dc2aad92ffa9 Mon Sep 17 00:00:00 2001 From: ydah Date: Sun, 8 Jun 2025 18:35:16 +0900 Subject: [PATCH 2/2] ci jruby: use Java 21 for jruby refs: https://github.com/ruby/strscan/commit/baa5de37a69e026c564d3fc6665b70ee4e610b19 refs: https://github.com/ruby/strscan/commit/a4afd32ab31b45c579e0bec1475eb276c4ac4ed2 --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3cfe7d3a..9e74ea9a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,6 +40,12 @@ jobs: - uses: ruby/setup-ruby@v1 with: ruby-version: ${{matrix.ruby}} + - uses: actions/setup-java@v4 + with: + distribution: zulu + java-version: 21 + if: >- + startsWith(matrix.ruby, 'jruby') - run: bundle install --jobs 4 --retry 3 - run: rake test - run: rake build