Class: NativeLoader
- Inherits:
-
Object
- Object
- NativeLoader
- Defined in:
- lib/picrate/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.
15 16 17 18 |
# File 'lib/picrate/native_loader.rb', line 15 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.
6 7 8 |
# File 'lib/picrate/native_loader.rb', line 6 def current_path @current_path end |
#separator ⇒ Object (readonly)
Returns the value of attribute separator.
6 7 8 |
# File 'lib/picrate/native_loader.rb', line 6 def separator @separator end |
Instance Method Details
#add_native_path(pth) ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/picrate/native_loader.rb', line 20 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 |