Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 16a049ac9223
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8de085925d5e
Choose a head ref
  • 3 commits
  • 2 files changed
  • 2 contributors

Commits on Nov 29, 2015

  1. each_object(cls.singleton_class) should not walk special classes.

    Special meaning singletons and included module wrappers.
    headius authored and kares committed Nov 29, 2015
    Copy the full SHA
    16c0d0f View commit details

Commits on Dec 1, 2015

  1. Copy the full SHA
    0759716 View commit details
  2. no singleton_class in 1.8.7

    kares committed Dec 1, 2015
    Copy the full SHA
    8de0859 View commit details
Showing with 16 additions and 11 deletions.
  1. +9 −5 core/src/main/java/org/jruby/RubyObjectSpace.java
  2. +7 −6 test/test_objectspace.rb
14 changes: 9 additions & 5 deletions core/src/main/java/org/jruby/RubyObjectSpace.java
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@
* Copyright (C) 2002-2004 Anders Bengtsson <ndrsbngtssn@yahoo.se>
* Copyright (C) 2004 Thomas E Enebo <enebo@acm.org>
* Copyright (C) 2004 Stefan Matthias Aust <sma@3plus4.de>
*
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
@@ -51,12 +51,12 @@
public class RubyObjectSpace {

/** Create the ObjectSpace module and add it to the Ruby runtime.
*
*
*/
public static RubyModule createObjectSpaceModule(Ruby runtime) {
RubyModule objectSpaceModule = runtime.defineModule("ObjectSpace");
runtime.setObjectSpaceModule(objectSpaceModule);

objectSpaceModule.defineAnnotatedMethods(RubyObjectSpace.class);

if (runtime.is2_0()) {
@@ -120,7 +120,7 @@ public static IRubyObject id2ref(IRubyObject recv, IRubyObject id) {
}
}
}

public static IRubyObject each_objectInternal(final ThreadContext context, IRubyObject recv, IRubyObject[] args, final Block block) {
RubyModule tmpClass;
if (args.length == 0) {
@@ -160,7 +160,11 @@ public Object apply(IRubyObject arg1) {
block.yield(context, attached);
if (attached instanceof RubyClass) {
for (RubyClass child : ((RubyClass)attached).subclasses(true)) {
block.yield(context, child);
if (child instanceof IncludedModuleWrapper || child.isSingleton()) {
// do nothing for included wrappers or singleton classes
} else {
block.yield(context, child);
}
}
}
} else {
13 changes: 7 additions & 6 deletions test/test_objectspace.rb
Original file line number Diff line number Diff line change
@@ -6,11 +6,11 @@ def setup
@objectspace = JRuby.objectspace
JRuby.objectspace = true
end

def teardown
JRuby.objectspace = @objectspace
end

def test_id2ref
# Normal objects
o1 = "hey"
@@ -42,14 +42,14 @@ def test_id2ref
assert_equal(true, ObjectSpace._id2ref(2))
assert_equal(nil, ObjectSpace._id2ref(4))
end

def test_jruby_objectspace
JRuby.objectspace = false
assert_equal(false, JRuby.objectspace)
JRuby.objectspace = true
assert_equal(true, JRuby.objectspace)
end

# JRUBY-4330
def test_object_id_same_with_objectspace
obj = "wahoo"
@@ -101,8 +101,9 @@ def test_each_object_singleton_class
d = Class.new(b)

classes = ObjectSpace.each_object(a.singleton_class).to_a
assert_equal(classes.sort_by(&:name), [a, b, c, d].sort_by(&:name))
assert_equal(classes.sort_by(&:object_id), [a, b, c, d].sort_by(&:object_id))
ensure
JRuby.objectspace = old_objectspace
end
end if RUBY_VERSION > '1.9'

end