Skip to content

Commit fd4f0ef

Browse files
committed
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
1 parent 3c72fbe commit fd4f0ef

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

Rakefile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,15 @@ if jruby?
6868
lib_dir = ext.lib_dir += "/#{ext.platform}/racc"
6969
ext.ext_dir = 'ext/racc'
7070
# source/target jvm
71-
ext.source_version = '1.8'
72-
ext.target_version = '1.8'
71+
if defined?(JRUBY_VERSION) && Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new('10.0.0.0')
72+
# Use Java 21 for JRuby 10.0.0.0 or higher
73+
ext.source_version = '21'
74+
ext.target_version = '21'
75+
else
76+
# Use Java 8 if its lower than JRuby 10.0.0.0
77+
ext.source_version = '1.8'
78+
ext.target_version = '1.8'
79+
end
7380
jars = ["#{jruby_home}/lib/jruby.jar"] + FileList['lib/*.jar']
7481
ext.classpath = jars.map { |x| File.expand_path x }.join( ':' )
7582
ext.name = 'cparse-jruby'

0 commit comments

Comments
 (0)