Skip to content
Browse files

An object's ID is not copied

Fixes JRUBY-7136

Signed-off-by: Wayne Meissner <wmeissner@gmail.com>
  • Loading branch information...
1 parent 1236613 commit 5c401c1ed734b9cf0865aee2331a66cd1c44c641 @alindeman alindeman committed with Wayne Meissner Mar 31, 2013
Showing with 12 additions and 1 deletion.
  1. +1 −1 src/org/jruby/RubyBasicObject.java
  2. +11 −0 test/test_object_id.rb
View
2 src/org/jruby/RubyBasicObject.java
@@ -1513,7 +1513,7 @@ public void syncVariables(IRubyObject other) {
System.arraycopy(otherTable, 0, currentTable, 0, otherTable.length);
// null out object ID so we don't share it
- if (objectIdIdx > 0 && objectIdIdx < currentTable.length) {
+ if (objectIdIdx >= 0 && objectIdIdx < currentTable.length) {
currentTable[objectIdIdx] = null;
}
View
11 test/test_object_id.rb
@@ -0,0 +1,11 @@
+require 'test/unit'
+
+class TestObjectId < Test::Unit::TestCase
+ def test_dup_object_gets_new_object_id
+ o = Object.new
+ o.__id__
+ o.instance_variable_set(:@foo, "foo")
+
+ assert_not_equal o.__id__, o.dup.__id__
+ end
+end

0 comments on commit 5c401c1

Please sign in to comment.
Something went wrong with that request. Please try again.