Skip to content
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

Add compiler-interface to the Scala Instance top loader #6199

Merged
merged 1 commit into from
Dec 11, 2020

Conversation

adpi2
Copy link
Member

@adpi2 adpi2 commented Dec 11, 2020

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 the compiler-interface classes from the same loader than sbt. Otherwise we have LinkageException.

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 the TestInterfaceClassLoader and I renamed it SbtInterfaceClassLoader.

The hierarchy of class loader now looks like this (the parents are at the bottom):

  • MetaBuildLoader: all sbt jars
  • FullScalaLoader: scala-xml_2.12, scala-compiler-2.12.12 and scala-reflect-2.12.12
  • LibraryLoader: scala-library-2.12.12
  • JLineLoader: jline jars
  • SbtInterfaceLoader: test-interface and compiler-interface
  • topLoader: JDK except Jansi

Depending on useScalaReplJLine the scalaInstanceTopLoader is JLineLoader (which contains SbtInterfaceLoader) or SbtInterfaceLoader directly.

I tested it successfully against the 3.0.0-M2 compiler and a snapshot of the future 3.0.0-M3 compiler.

@adpi2 adpi2 requested a review from eatkins December 11, 2020 11:14
@adpi2 adpi2 marked this pull request as ready for review December 11, 2020 11:14
Copy link
Contributor

@eatkins eatkins left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants