Add compiler-interface to the Scala Instance top loader #6199
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.
The Scala 3 compiler now has a direct dependency on the
org.scala-sbt:compiler-interface
artifact. When compiling, it is crucial that its loads thecompiler-interface
classes from the same loader than sbt. Otherwise we haveLinkageException
.In this PR I moved the
compiler-interface
up in the class loader hierarchy. It is safe because it's a pure java API that has no dependency. Rather than introducing a new loader in the pile of class loaders, I reused theTestInterfaceClassLoader
and I renamed itSbtInterfaceClassLoader
.The hierarchy of class loader now looks like this (the parents are at the bottom):
MetaBuildLoader
: all sbt jarsFullScalaLoader
:scala-xml_2.12
,scala-compiler-2.12.12
andscala-reflect-2.12.12
LibraryLoader
:scala-library-2.12.12
JLineLoader
: jline jarsSbtInterfaceLoader
:test-interface
andcompiler-interface
Depending on
useScalaReplJLine
thescalaInstanceTopLoader
isJLineLoader
(which containsSbtInterfaceLoader
) orSbtInterfaceLoader
directly.I tested it successfully against the
3.0.0-M2
compiler and a snapshot of the future3.0.0-M3
compiler.