Created
January 11, 2012 16:20
-
-
Save djberg96/1595421 to your computer and use it in GitHub Desktop.
Problem with private_class_method using JRuby
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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