sys-proctable: Undefined method read_uint64 in JRuby.

I noticed this error in my Macbook while trying to run ProcTable.ps(:pid => Process.pid).cmdline.split(' ').

jruby-head :001 > RUBY_VERSION
 => "2.5.3" 
jruby-head :002 > require 'sys/proctable'
 => true 
jruby-head :003 > include Sys
 => Object 
jruby-head :004 > ProcTable.ps(:pid => Process.pid).cmdline.split(' ')
Traceback (most recent call last):
       10: from /Users/adpentela/.rvm/rubies/jruby-head/bin/irb:13:in `<main>'
        9: from org/jruby/RubyKernel.java:1193:in `catch'
        8: from org/jruby/RubyKernel.java:1193:in `catch'
        7: from org/jruby/RubyKernel.java:1425:in `loop'
        6: from org/jruby/RubyKernel.java:1061:in `eval'
        5: from (irb):4:in `evaluate'
        4: from /Users/adpentela/.rvm/gems/jruby-head/gems/sys-proctable-1.2.1/lib/darwin/sys/proctable.rb:199:in `ps'
        3: from /Users/adpentela/.rvm/gems/jruby-head/gems/sys-proctable-1.2.1/lib/darwin/sys/proctable.rb:286:in `get_thread_info'
        2: from org/jruby/RubyInteger.java:209:in `upto'
        1: from /Users/adpentela/.rvm/gems/jruby-head/gems/sys-proctable-1.2.1/lib/darwin/sys/proctable.rb:288:in `block in get_thread_info'
NoMethodError (undefined method `read_uint64' for #<FFI::Pointer address=0x7f81cee78510 size=208>)
Did you mean?  read_uint
               read_int
               get_uint64
jruby-head :005 > 

I tried to see if I can get this working by using the alternatives suggested in the error message but it still results in an error.

Here are my environment specifics:

$ uname -a
Darwin MB-ADPENTELA.local 17.4.0 Darwin Kernel Version 17.4.0: Sun Dec 17 09:19:54 PST 2017; root:xnu-4570.41.2~1/RELEASE_X86_64 x86_64

$ ruby -v
jruby 9.2.7.0 (2.5.3) 2019-04-09 8a269e3 Java HotSpot(TM) 64-Bit Server VM 25.191-b12 on 1.8.0_191-b12 +jit [darwin-x86_64]

$ java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@adi-pen Thanks. I’ll probably wait a while to remove the previous changes since I imagine people will be running older versions of JRuby for a time.

This will be fixed for jruby/jruby#5947 by jruby/jruby#5948. Thanks for working around it! Hopefully with the FFIs synched up we won’t see these sorts of incompatibilities.

@Adithya-copart Looks like this will workaround will work for the CharArray issue:

unless defined? FFI::StructLayout::CharArray
    FFI::StructLayout::CharArray = FFI::StructLayout::CharArrayProxy
end

@Adithya-copart Try read_ulong_long and see how that goes.