class NativeLoader

This class knows how to dynamically set the 'java' native library path It might not work with java 9?

Attributes

current_path[R]
separator[R]

Public Class Methods

new() click to toggle source
# File lib/jruby_art/native_loader.rb, line 14
def initialize
  @separator = JC::File.pathSeparatorChar
  @current_path = JC::System.getProperty('java.library.path')
end

Public Instance Methods

add_native_path(pth) click to toggle source
# File lib/jruby_art/native_loader.rb, line 19
def add_native_path(pth)
  current_path << separator << pth
  JC::System.setProperty('java.library.path', current_path)
  field = JC::Class.for_name('java.lang.ClassLoader')
                   .get_declared_field('sys_paths')
  return unless field

  field.accessible = true # some jruby magic
  field.set(JC::Class.for_name('java.lang.System').get_class_loader, nil)
end