Skip to content

[FFI] JRuby 1.7.0 does not allow context parameter of to_native to be optional #379

@Burgestrand

Description

@Burgestrand

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions