10000 Fixes to improve Zeitwerk support by headius · Pull Request #8852 · jruby/jruby · GitHub
[go: up one dir, main page]

Skip to content

Fixes to improve Zeitwerk support #8852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jun 9, 2025
Merged

Conversation

headius
Copy link
Member
@headius headius commented May 29, 2025

Various fixes to try to get Zeitwerk green on JRuby 10.

See #6781.

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.
@fxn
Copy link
fxn commented May 29, 2025

❤️

headius added 5 commits May 29, 2025 15:57
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.
@headius headius marked this pull request as ready for review June 9, 2025 09:02
@headius
Copy link
Member Author
headius commented Jun 9, 2025

Merging to make sure these fixes get into 10.0.1.0. We'll look at the remaining issues in #8863.

@headius headius added this to the JRuby 10.0.1.0 milestone Jun 9, 2025
@headius headius merged commit bad6ac7 into jruby:master Jun 9, 2025
72 checks passed
@headius headius deleted the zeitwerk_fixes branch June 9, 2025 09:02
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.

2 participants
0