Make autoload dynamically dispatch to require. Fixes #5403.#5404
Make autoload dynamically dispatch to require. Fixes #5403.#5404enebo merged 2 commits intojruby:masterfrom
Conversation
|
Ping #5403. |
|
@headius I don't know if this helps, but it looks like the assertion is testing that there are no warnings and the warnings are coming from RubyGems (this is from the test failure output): I noticed this particular test comes from MRI. Here is the JRuby version, and here is the MRI version. These look mostly the same, except for the MJIT thing. However, they both call It could be that disabling RubyGems will fix this test (addressing the warning in RubyGems may have nothing to do with JRuby). |
|
@tenderlove Thank you! I just circled back to this today, so I'll look into your theory. |
|
It looks like that disabling of RubyGems didn't happen until this summer, but the tests that we're failing are certainly from long before that. |
|
Ok, so the problem here is the same thing as #3656, where an explicit require of an autoloaded file does not remove that autoload from firing again. Here's a trivial reproduction: atest/a.rb class A
autoload :B, 'atest/b'
end
require 'atest/b'atest/b.rb class A::B
endThe normal require starts the process of loading atest/b.rb. That file then attempts to (re)open A::B, which triggers the autoload detection. Autoload does not check if there's a require of that file already in progress before proceeding to dynamically invoke I am working through CRuby logic for this. I believe what's missing is the |
|
Yes, that's basically the issue. This all feeds back into us not having the same search and caching capabilities for load paths, expanded paths, and loaded features that MRI does. I ported over the "loaded_feature_path" method and added a loop over all currently-loading scripts, as is done in the rb_feature_p function. CRuby checks for an existing feature in the following ways, if I'm following right:
So basically, we're missing most of the search logic that MRI does during rb_feature_p because we don't walk through the whole load path (with pre-expanded paths) and look for the long name. See also #2794. @enebo It's time we bit the bullet and matched their searches, at least, which will likely necessitate incorporating the same caching. |
31d1414 to
9c35116
Compare
|
Rebased atop master with the |
|
@headius yeah if we need this for rails 6 then matching MRI search logic will definitely be the fastest path to a stable release. |
We'll see how this fares in CI.