Cleanups and improvements for java_import#6116
Merged
headius merged 3 commits intojruby:masterfrom Mar 10, 2020
Merged
Conversation
e4ceeee to
8c47219
Compare
`java_import` has been defined on Object for many years, but after all that time it seems it really should have been defined on Module and toplevel only, similar to the visibility methods and `define_method`. In addition, it uses unnecessary evals to query and assign the constant, and if called against a non-Module it always defines the resulting constant on Object. This leads to peculiar behavior as reported in jruby#6115. This change does the following: * Deprecate and warn for java_import called against arbitrary non-Module objects. * Move java_import to Module and define a top-level version that invokes it against Object. * Eliminate the eval and use const* methods to assign the value. This should be a bit faster (no evals) and provide a path toward removing Object#java_import. All spec:ji passes without any warnings, so at least we are not using Object#java_import there.
8c47219 to
4f96b5d
Compare
* Move doco to Module#java_import. * Delete deprecated include_class and java_kind_of. * Add @deprecated and :nodoc: to Object#java_import. * Link toplevel java_import doco to Module#java_import.
Module#import called super, which would fall through Object#java_import eventually and trigger a warning. Invoke Module#java_import directly instead.
Member
Author
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 contains commits to clean up
java_importand bring up to date with modern Ruby patterns.Inspired by #6115.