Fixes to improve Zeitwerk support#8852
Merged
headius merged 7 commits intojruby:masterfrom Jun 9, 2025
Merged
Conversation
Non-ASCII constant names were being rejected here.
Fixes one failure in Zeitwerk that expected Module#hash to be called when a module was a key in a Hash.
|
❤️ |
Updating the visibility of an constant being defined for autoload caused that autoload constant to be set to UNDEF without the new visibility, because the logic did not handle UNDEF values (our marker for an autoloading constant). The changes here check for undef and update the autoload instead of the constant table. Also modified is tweaking Autoload to only update the value if the incoming newValue is not null or UNDEF, which may happen due to the way that constant visibility updates happen. Fixes one failure in Zeitwerk relating to private autoloading constants.
When a constant is currently being autoloaded, we should still invoke const_added to indicate that someone set it. This was the cause of most Zeitwerk problems: an autoload gets registered for the constant associated with the current file, and when that constant gets assigned it should trigger further autoload registrations for e.g. subdirs of a gem.
The #hash method will return another JavaPackage, which obviously isn't useful.
There are three situations: 1. When a constant does not exist and we don't provide a hidden flag, default to false (public). 2. When a constant already exists (or is being autoloaded) and we don't provide a hidden flag, leave the existing value in place. 3. When a hidden flag is explicitly provided, use that value.
User-defined modules might redefine #hash so we can't rely on the hashCode always working as expected.
Member
Author
|
Merging to make sure these fixes get into 10.0.1.0. We'll look at the remaining issues in #8863. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Various fixes to try to get Zeitwerk green on JRuby 10.
See #6781.