RFC: Do not add CLASSPATH to the module path#5728
Merged
headius merged 1 commit intojruby:masterfrom May 14, 2019
Merged
Conversation
Treating the CLASSPATH as modules will create automatic modules for all entries that are not actually modules. This can lead to several problems, e.g. the automatic module name is determined by the name of the jar or directory, which fails when one component is not a valid java identifier. Another issue is that several automatic modules might export the same package, which is not allowed and leads to an error. To fix these issues, we can use the module path just for jruby libraries and pass the CLASSPATH using -classpath, as both can be combined. TODO: - Should $CP also go into the module path? - What about the other starters?
Member
|
@kschoelhorn Good catch...I did not think about other libraries being on classpath since most Rubyists will require jars at runtime (which then load through URLClassLoader). I will review. We will need an equivalent change for https://github.com/jruby/jruby-launcher. |
headius
approved these changes
May 14, 2019
|
Regarding open questions: please note, classpath and modulepath are for different purpose and entries from one should not go to the another one. So as a user one should be able to specify both at same time without a fear that jruby does a happy mix from them. |
Member
|
Regarding your additional questions:
|
|
Thanks for merging this so fast! I will try to create a PR for jruby-launcher tomorrow. (This is my private account) |
kschoelhorn
added a commit
to kschoelhorn/jruby-launcher
that referenced
this pull request
May 15, 2019
Treating the CLASSPATH as modules will create automatic modules for all entries that are not actually modules. This can lead to several problems, e.g. the automatic module name is determined by the name of the jar or directory, which fails when one component is not a valid java identifier. Another issue is that several automatic modules might export the same package, which is not allowed and leads to an error. To fix these issues, we use the module path just for jruby libraries and pass the CLASSPATH using -classpath, as both can be combined. This is identical to the fix for jruby.bash in jruby/jruby (20e4278) [1]. [1]: jruby/jruby#5728
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.
960efcb and 7c4bf9c changed the starter so that the
$CLASSPATHis added to the module path when running on java9+.Treating the CLASSPATH as modules will create automatic modules for all entries that are not actually modules. This can lead to several problems, e.g. the automatic module name is determined by the name of the jar or directory, which fails when one component is not a valid java identifier. Another issue is that several automatic modules might export the same package, which is not allowed and leads to an error.
While the first problems is relatively easy to fix, the second one requires large changes and might not even possible if you are using third-party libraries (e.g. we are using UNO, which has problems with this).
To fix these issues, we can use the module path just for jruby libraries and pass the CLASSPATH using
-classpath, as both can be combined.Note that I haven't done extensive testing, because I first wanted to hear what you think about this approach.
Unresolved questions: