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: 4760e9f7b2dd
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 740bdb4b4b13
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Nov 24, 2015

  1. Copy the full SHA
    ba39124 View commit details
  2. each_object(cls.singleton_class) should not walk special classes.

    Special meaning singletons and included module wrappers.
    headius committed Nov 24, 2015
    Copy the full SHA
    740bdb4 View commit details
Showing with 5 additions and 18 deletions.
  1. +5 −1 core/src/main/java/org/jruby/RubyObjectSpace.java
  2. +0 −17 test/jruby/test_objectspace.rb
6 changes: 5 additions & 1 deletion core/src/main/java/org/jruby/RubyObjectSpace.java
Original file line number Diff line number Diff line change
@@ -158,7 +158,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 IncludedModule || child.isSingleton()) {
// do nothing for included wrappers or singleton classes
} else {
block.yield(context, child);
}
}
}
} else {
17 changes: 0 additions & 17 deletions test/jruby/test_objectspace.rb
Original file line number Diff line number Diff line change
@@ -93,21 +93,4 @@ def test_finalization
assert_equal "finalizing #{results[0]}", results[1]
end
end

# See rails/rails#22376.
def test_each_object_singleton_class
# disable objectspace; we want this to always work
old_objectspace = JRuby.objectspace
JRuby.objectspace = false

a = Class.new
b = Class.new(a)
c = Class.new(a)
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))
ensure
JRuby.objectspace = old_objectspace
end
end