File tree 2 files changed +14
-2
lines changed
2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -475,8 +475,11 @@ class Handle
475
475
RTLD_NOW = FFI ::DynamicLibrary ::RTLD_NOW
476
476
477
477
def initialize ( libname = nil , flags = RTLD_LAZY | RTLD_GLOBAL )
478
- @lib = FFI ::DynamicLibrary . open ( libname , flags ) rescue LoadError
479
- raise DLError . new ( "Could not open #{ libname } " ) unless @lib
478
+ begin
479
+ @lib = FFI ::DynamicLibrary . open ( libname , flags )
480
+ rescue LoadError , RuntimeError # LoadError for JRuby, RuntimeError for TruffleRuby
481
+ raise DLError , "Could not open #{ libname } "
482
+ end
480
483
481
484
@open = true
482
485
Original file line number Diff line number Diff line change @@ -8,6 +8,15 @@ module Fiddle
8
8
class TestHandle < TestCase
9
9
include Fiddle
10
10
11
+ def test_library_unavailable
12
+ assert_raise ( DLError ) do
13
+ Fiddle ::Handle . new ( "does-not-exist-library" )
14
+ end
15
+ assert_raise ( DLError ) do
16
+ Fiddle ::Handle . new ( "/does/not/exist/library.#{ RbConfig ::CONFIG [ 'SOEXT' ] } " )
17
+ end
18
+ end
19
+
11
20
def test_to_i
12
21
if ffi_backend?
13
22
omit ( "Fiddle::Handle#to_i is unavailable with FFI backend" )
You can’t perform that action at this time.
0 commit comments