Skip to content

Don't restrict object search to modules#9031

Merged
headius merged 2 commits into
jruby:jruby-9.4from
headius:also_search_object_for_classes
Oct 23, 2025
Merged

Don't restrict object search to modules#9031
headius merged 2 commits into
jruby:jruby-9.4from
headius:also_search_object_for_classes

Conversation

@headius

@headius headius commented Oct 23, 2025

Copy link
Copy Markdown
Member

I'm unsure why this change is here but I could find no equivalent logic in CRuby and this appears to prevent the search detailed in #8924 from succeeding. Removing this restriction fixes that issue.

Fixes #8924

I'm unsure why this change is here but I could find no equivalent
logic in CRuby and this appears to prevent the search detailed in
jruby#8924 from succeeding. Removing this restriction fixes
that issue.

Fixes jruby#8924
@headius headius added this to the JRuby 9.4.15.0 milestone Oct 23, 2025
@headius

headius commented Oct 23, 2025

Copy link
Copy Markdown
Member Author

I traced this particular !isClass check back as far as 2008. Could be behavior that changed since then in Ruby proper.

The final Object search should not be done when the target class
descends from BasicObject instead of Object. We test this by
checking its allocator against the default RubyBasicObject
allocator.
@headius headius force-pushed the also_search_object_for_classes branch from 2a064ae to f51a112 Compare October 23, 2025 20:49
@headius

headius commented Oct 23, 2025

Copy link
Copy Markdown
Member Author

An additional patch here limits the Object search to only modules and classes that descend from Object, excluding BasicObject descendants. Without this, specs for defined? Kernel within a BasicObject descendant failed (Kernel should not be found).

it "does not define built-in constants (according to defined?)" do
BasicObjectSpecs::BOSubclass.kernel_defined?.should be_nil
end

@headius headius merged commit 836cfd4 into jruby:jruby-9.4 Oct 23, 2025
97 checks passed
@headius headius deleted the also_search_object_for_classes branch October 23, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

const_defined? returns false for External Constants in JRuby 10.0.1.0 and 9.4.14.0

1 participant