Avoid binding unreadable modules' classes#8996
Merged
headius merged 2 commits intojruby:masterfrom Sep 9, 2025
Merged
Conversation
We should not attempt to read public classes from modules that are not readable from the JRuby module. Alternative fix for jruby#8987. Original fix in jruby#8989 approached this differently by requesting read access to the module. Further discussion in the related OpenJDK core-libs-dev thread lead to the realization that the generated proxy class from jruby#8987 was in an internal JDK module and not intended to be readable by anyone, but we were attempting to find it. The fix here avoids binding classes from modules that are not naturally readable from the JRuby module, rather than trying to add more reads than were originally configured or requested.
Modules that are not naturally readable should not be added to reads just so we can get access to their methods. Any logic that is passing unreadable modules' classes and methods to this logic should reexamine how those classes and methods are being acquired, and add reads at that point or avoid acquiring references to such unreadable modules. See jruby#8989 for the original patch, as a fix for jruby#8987. The OpenJDK core-libs-dev discussion linked from that issue led us to a new fix that avoids binding unreadable modules' classes in our Java integration layer.
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.
This PR is an alternative (and probably more correct) fix for #8987, and does the following:
This fixes the issues in #8987 without adding new module reads for every method handle acquisition.
See the following OpenJDK core-libs-dev discussion for details: https://mail.openjdk.org/pipermail/core-libs-dev/2025-September/151017.html