Class: NativeLoader
- Inherits:
-
Object
- Object
- NativeLoader
- Defined in:
- lib/jruby_art/native_loader.rb
Overview
This class knows how to dynamically set the ‘java’ native library path It might not work with java 9?
Defined Under Namespace
Modules: JC
Instance Attribute Summary collapse
-
#current_path ⇒ Object
readonly
Returns the value of attribute current_path.
-
#separator ⇒ Object
readonly
Returns the value of attribute separator.
Instance Method Summary collapse
- #add_native_path(pth) ⇒ Object
-
#initialize ⇒ NativeLoader
constructor
A new instance of NativeLoader.
Constructor Details
#initialize ⇒ NativeLoader
Returns a new instance of NativeLoader.
12 13 14 15 |
# File 'lib/jruby_art/native_loader.rb', line 12 def initialize @separator = JC::File.pathSeparatorChar @current_path = JC::System.getProperty('java.library.path') end |
Instance Attribute Details
#current_path ⇒ Object (readonly)
Returns the value of attribute current_path.
4 5 6 |
# File 'lib/jruby_art/native_loader.rb', line 4 def current_path @current_path end |
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
4 5 6 |
# File 'lib/jruby_art/native_loader.rb', line 4 def separator @separator end |
Instance Method Details
#add_native_path(pth) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/jruby_art/native_loader.rb', line 17 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 |