Skip to content

Instantly share code, notes, and snippets.

@djberg96
Created January 11, 2012 16:20
Show Gist options
  • Save djberg96/1595421 to your computer and use it in GitHub Desktop.
Save djberg96/1595421 to your computer and use it in GitHub Desktop.
Problem with private_class_method using JRuby
require 'ffi'
module Sys
class Filesystem
extend FFI::Library
ffi_lib FFI::Library::LIBC
if RbConfig::CONFIG['host_os'] =~ /darwin|osx|mach/i
attach_function(:getmntinfo, :getmntinfo64, [:pointer, :int], :int)
else
attach_function(:getmntinfo, [:pointer, :int], :int)
end
# This seems to be the problem for JRuby
private_class_method :getmntinfo
def self.mounts
if method_defined?(:getmntinfo)
puts "YEP"
else
puts "NOPE"
end
end
end
end
# MRI returns "YEP", JRuby returns "NOPE"
Sys::Filesystem.mounts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment