For data converters, the context parameter of to_native and from_native cannot be optional, JRuby raising an issue about required number of parameters should be two. I’ve stripped comments in the code for brevity.
Ran into this issue trying an FFI project of mine on JRuby. Here’s a commit I made so JRuby would accept the code: Burgestrand/spotify@8deb3ad
Failing example code:
module UTF8String
extend FFI::DataConverter
native_type FFI::Type::STRING
class << self
def to_native(value, ctx = nil)
value && value.encode('UTF-8')
end
def from_native(value, ctx = nil)
value && value.force_encoding('UTF-8')
end
end
end