Skip to content
This repository was archived by the owner on Mar 15, 2022. It is now read-only.

Commit 2716bf7

Browse files
committed
Replaces compiled Java with JRuby interop
1 parent 6d4d69c commit 2716bf7

File tree

7 files changed

+33
-121
lines changed

7 files changed

+33
-121
lines changed

ext/java/org/jruby/ext/ref/ReferencesService.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

ext/java/org/jruby/ext/ref/RubySoftReference.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

ext/java/org/jruby/ext/ref/RubyWeakReference.java

Lines changed: 0 additions & 43 deletions
This file was deleted.

lib/org/jruby/ext/ref/references.jar

-4.44 KB
Binary file not shown.

lib/ref.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ module Ref
77

88
# Set the best implementation for weak references based on the runtime.
99
if defined?(RUBY_PLATFORM) && RUBY_PLATFORM == 'java'
10-
# Use native Java references
11-
begin
12-
$LOAD_PATH.unshift(File.dirname(__FILE__))
13-
require 'org/jruby/ext/ref/references'
14-
ensure
15-
$LOAD_PATH.shift if $LOAD_PATH.first == File.dirname(__FILE__)
16-
end
10+
$LOAD_PATH.unshift(File.dirname(__FILE__))
11+
require 'ref/jruby/weak_reference'
12+
require 'ref/jruby/soft_reference'
13+
14+
$LOAD_PATH.shift if $LOAD_PATH.first == File.dirname(__FILE__)
1715
else
1816
require 'ref/soft_reference'
1917
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ironruby'

lib/ref/jruby/soft_reference.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module Ref
2+
3+
class SoftReference < Reference
4+
def initialize(obj)
5+
@_ref = java.lang.ref.SoftReference.new(obj)
6+
@referenced_object_id = obj.__id__
7+
end
8+
9+
def object
10+
@_ref.get()
11+
end
12+
end
13+
end

lib/ref/jruby/weak_reference.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module Ref
2+
class WeakReference < Reference
3+
4+
def initialize(obj)
5+
@_ref = java.lang.ref.WeakReference.new(obj)
6+
@referenced_object_id = obj.__id__
7+
end
8+
9+
def object
10+
@_ref.get()
11+
end
12+
13+
end
14+
15+
end

0 commit comments

Comments
 (0)