-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WIP] 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
40
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.
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
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.
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.tools.repol.shadednamespace, 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 belowThe PPrint/Fansi/Sourcecode libraries cannot be 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
Fixes #24382