Skip to content

Commit b4a1c94

Browse files
committed
Require java extensions on JRuby
1 parent f6b29a7 commit b4a1c94

File tree

7 files changed

+11
-12
lines changed

7 files changed

+11
-12
lines changed

Rakefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
$:.push File.join(File.dirname(__FILE__), 'lib')
44

55
require 'concurrent/version'
6-
require 'concurrent/synchronization'
76
require 'concurrent/utility/native_extension_loader'
87

98
## load the gemspec files

lib/concurrent/map.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require 'thread'
22
require 'concurrent/constants'
33
require 'concurrent/utility/native_extension_loader'
4+
Concurrent.load_native_extensions
45

56
module Concurrent
67
# @!visibility private

lib/concurrent/synchronization.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
require 'concurrent/synchronization/abstract_object'
44
require 'concurrent/utility/native_extension_loader' # load native parts first
5+
Concurrent.load_native_extensions
56

67
require 'concurrent/synchronization/mri_object'
78
require 'concurrent/synchronization/jruby_object'

lib/concurrent/synchronization/lockable_object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Synchronization
88
MriMonitorLockableObject
99
when Concurrent.on_cruby? && Concurrent.ruby_version(:>, 1, 9, 3)
1010
MriMutexLockableObject
11-
when defined? JRubyLockableObject
11+
when Concurrent.on_jruby?
1212
JRubyLockableObject
1313
when Concurrent.on_rbx? || Concurrent.on_truffle?
1414
RbxLockableObject

lib/concurrent/synchronization/object.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module Synchronization
66
ObjectImplementation = case
77
when Concurrent.on_cruby?
88
MriObject
9-
when defined? JRubyObject
9+
when Concurrent.on_jruby?
1010
JRubyObject
1111
when Concurrent.on_rbx? || Concurrent.on_truffle?
1212
RbxObject

lib/concurrent/synchronization/volatile.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,10 @@ module Synchronization
2525
MriAttrVolatile
2626
when Concurrent.on_jruby?
2727
JRubyAttrVolatile
28-
when Concurrent.on_rbx?
28+
when Concurrent.on_rbx? || Concurrent.on_truffle?
2929
RbxAttrVolatile
3030
else
31-
warn 'Possibly unsupported Ruby implementation'
3231
MriAttrVolatile
3332
end
3433
end
35-
end
34+
end

lib/concurrent/utility/native_extension_loader.rb

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
module Concurrent
44

5-
unless defined? Synchronization::AbstractObject
6-
raise 'native_extension_loader loaded before Synchronization::AbstractObject'
7-
end
8-
95
module Utility
106

117
# @!visibility private
@@ -32,6 +28,10 @@ def set_java_extensions_loaded
3228
end
3329

3430
def load_native_extensions
31+
unless defined? Synchronization::AbstractObject
32+
raise 'native_extension_loader loaded before Synchronization::AbstractObject'
33+
end
34+
3535
if Concurrent.on_cruby? && !c_extensions_loaded?
3636
tries = [
3737
lambda do
@@ -60,7 +60,7 @@ def load_native_extensions
6060
set_java_extensions_loaded
6161
rescue LoadError
6262
# move on with pure-Ruby implementations
63-
warn 'On JRuby but Java extensions failed to load.'
63+
raise 'On JRuby but Java extensions failed to load.'
6464
end
6565
end
6666
end
@@ -71,4 +71,3 @@ def load_native_extensions
7171
extend Utility::NativeExtensionLoader
7272
end
7373

74-
Concurrent.load_native_extensions

0 commit comments

Comments
 (0)