diff --git a/lib/ffi.rb b/lib/ffi.rb index bcbc59c46..64f3871b1 100644 --- a/lib/ffi.rb +++ b/lib/ffi.rb @@ -8,10 +8,14 @@ require 'ffi/ffi' -elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(JRUBY_VERSION) >= Gem::Version.new("9.3.pre") +elsif RUBY_ENGINE == 'jruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("9.3.pre") JRuby::Util.load_ext("org.jruby.ext.ffi.FFIService") require 'ffi/ffi' +elsif RUBY_ENGINE == 'truffleruby' && Gem::Version.new(RUBY_ENGINE_VERSION) >= Gem::Version.new("20.1.0") + require 'truffleruby/ffi_backend' + require 'ffi/ffi' + else # Remove the ffi gem dir from the load path, then reload the internal ffi implementation $LOAD_PATH.delete(File.dirname(__FILE__))