-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Provided a repl-embedded artifact which shades and isolates everything to avoid conflicts
#24494
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
Open
lihaoyi
wants to merge
44
commits into
scala:main
Choose a base branch
from
lihaoyi:embedded-repl
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+421
−42
Conversation
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
repl-embedded artifact which shades everything to avoid conflictsrepl-embedded artifact which shades everything to avoid conflicts
# Conflicts: # repl/src/dotty/tools/repl/ReplMain.scala # repl/test/dotty/tools/repl/ReplMainTest.scala
repl-embedded artifact which shades everything to avoid conflictsrepl-embedded artifact which shades and isolates everything to avoid conflicts
repl-embedded artifact which shades and isolates everything to avoid conflictsrepl-embedded artifact which shades and isolates everything to avoid conflicts
Contributor
Author
|
This should be ready for review I think, CC @Gedochao since you seem to be the one who always assigns people |
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.
Fixes #24382
This PR re-implements the shading and classpath isolation first implemented in #23849, but lost in the churn of #24243. It implements both the original source-based shading of PPrint/Fansi/Sourcecode, with additional classloader-based isolation of REPL implementation classes to further avoid conflicts with libraries on the user classpath
replcontains the current implementation of the Scala3 REPLrepl-embeddedis the assembly jar ofrepl, containing all the transitive classfiles, but moved under thedotty.isolatednamespace.repl-embeddedcontains three main un-isolated things:scala.tools.repl.EmbeddedReplMain, which spawns an isolated classloader that knows how to load stuff from thedotty.isolatednamespace, and uses that to instantiate aReplDriverdotty.shaded.*via source code mangling but are not classloader-isolated from user codescala-library.jar, which is guaranteed to be the same anywayThis approach allows anyone using the
repl-embeddedartifact to be confident there will not be classpath conflicts with their own classpath, since all the Scala compiler jars and transitive dependencies are isolated within a classloader and will not collide with user code. Furthermore, this allows us to begin using arbitrary third-party dependencies in thescala3-repl's implementation without them bleeding into user code inside or outside the REPL, with a few exceptions like PPrint/Fansi/Sourcecode below. Compared to the earlier implementation in #23849, this provides much stronger isolation from the enclosing classpath and avoids leaking implementation dependencies likecoursierapiinto the enclosing scopeThe PPrint/Fansi/Sourcecode libraries cannot be fully isolated because they need to be present in the same classloader as user code in order for PPrint logic like
case s: Seq[_] =>to work correctly: if they were in a separate classloader, theSeqin PPrint would differ from theSeqin user code, and these type tests would all fail. And due to the REPL interrupt instrumentation implemented in #24194, the REPL-code-classloader will ~always be different from the external user code classloader, so the PPrint/Fansi/Sourcecode classes have to be in that classloader to make things work and the only way to make it workTested manually to verify that the REPL classes do not appear on the classpath
Note that both within the REPL and outside the REPL in the enclosing codebase,
dotty.tools.repl.Maincannot be resolved. That is an improvement over the status quo wheredotty.tools.repl.Mainand it's dependencies likecoursierapicould conflict with things on the user classpath