Skip to content

Frozen string literal warning with FFI and JRuby 10 #8787

@ankane

Description

@ankane

FFI currently produces a frozen string literal warning with JRuby 10 when passing a string to an FFI function when the argument type is :pointer. This affects Fiddle with the char * type (ruby/fiddle#177).

require "ffi"

module Hello
  extend FFI::Library
  ffi_lib FFI::Library::LIBC
  attach_function :puts, [:pointer], :int # no warning if [:string]
end

Hello.puts("world")  # warning
Hello.puts(+"world") # no warning

And run with:

RUBYOPT="--debug-frozen-string-literal" ruby repro.rb

Environment Information

  • jruby 10.0.0.0 (3.4.2) 2025-04-13 6ed59bc OpenJDK 64-Bit Server VM 21.0.6 on 21.0.6 +indy +jit [arm64-darwin]
  • macOS 15.4.1 arm64

Expected Behavior

No warning

Actual Behavior

repro.rb:9: warning: literal string will be frozen in the future, the string was created here: repro.rb:9

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