Skip to content

Commit a3a16a8

Browse files
committed
Stop using the bootclasspath for Java 9 compatibility
It's no longer introspectable under Java 9. The scalac 2.12 shell scripts work around this by passing the bootclasspath jars as an additional system property, but we can avoid this complication by just using -classpath instead. This may have a slight negative impact on startup performance since the JVM bytecode verifier is not run for classes from the bootclasspath, but we can worry about that later.
1 parent 4752dc7 commit a3a16a8

File tree

4 files changed

+27
-34
lines changed

4 files changed

+27
-34
lines changed

bench/src/main/scala/Benchmarks.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ object Bench {
3737
val libs = System.getProperty("BENCH_CLASS_PATH")
3838

3939
val opts = new OptionsBuilder()
40-
.jvmArgsPrepend("-Xbootclasspath/a:" + libs + ":", "-Xms2G", "-Xmx2G")
40+
.jvmArgsPrepend(s"-classpath $libs", "-Xms2G", "-Xmx2G")
4141
.mode(Mode.AverageTime)
4242
.timeUnit(TimeUnit.MILLISECONDS)
4343
.warmupIterations(warmup)

compiler/test/dotty/Jars.scala

+5-4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ package dotty
22

33
/** Jars used when compiling test, normally set from the sbt build */
44
object Jars {
5+
def scalaLibrary: String = sys.env.get("DOTTY_SCALA_LIBRARY")
6+
.getOrElse(findJarFromRuntime("scala-library"))
7+
58
/** Dotty library Jar */
69
val dottyLib: String = sys.env.get("DOTTY_LIB")
710
.getOrElse(Properties.dottyLib)
@@ -36,14 +39,12 @@ object Jars {
3639

3740
/** Dotty test dependencies */
3841
val dottyTestDeps: List[String] =
39-
dottyLib :: dottyCompiler :: dottyInterfaces :: jlineTerminal :: jlineReader :: dottyExtras
42+
scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: jlineTerminal :: jlineReader :: dottyExtras
4043

4144
/** Dotty runtime with compiler dependencies, used for quoted.Expr.run */
4245
lazy val dottyRunWithCompiler: List[String] =
43-
dottyLib :: dottyCompiler :: dottyInterfaces :: scalaAsm :: Nil
46+
scalaLibrary :: dottyLib :: dottyCompiler :: dottyInterfaces :: scalaAsm :: Nil
4447

45-
def scalaLibrary: String = sys.env.get("DOTTY_SCALA_LIBRARY")
46-
.getOrElse(findJarFromRuntime("scala-library"))
4748

4849
/** Gets the scala 2.* library at runtime, note that doing this is unsafe
4950
* unless you know that the library will be on the classpath of the running

dist/bin/dotc

+1-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ fi
2828
source "$PROG_HOME/bin/common"
2929

3030
default_java_opts="-Xmx768m -Xms768m"
31-
bootcp=true
3231
withCompiler=true
3332

3433
CompilerMain=dotty.tools.dotc.Main
@@ -70,11 +69,7 @@ classpathArgs () {
7069
toolchain+="$JLINE_TERMINAL$PSEP"
7170
toolchain+="$JLINE_TERMINAL_JNA"
7271

73-
if [[ -n "$bootcp" ]]; then
74-
jvm_cp_args="-Xbootclasspath/a:\"$toolchain\""
75-
else
76-
jvm_cp_args="-classpath \"$toolchain\""
77-
fi
72+
jvm_cp_args="-classpath \"$toolchain\""
7873
}
7974

8075
while [[ $# -gt 0 ]]; do
@@ -92,8 +87,6 @@ case "$1" in
9287
-decompile) PROG_NAME="$DecompilerMain" && shift ;;
9388
-print-tasty) PROG_NAME="$DecompilerMain" && addScala "-print-tasty" && shift ;;
9489
-run) PROG_NAME="$ReplMain" && shift ;;
95-
-bootcp) bootcp=true && shift ;;
96-
-nobootcp) unset bootcp && shift ;;
9790
-colors) colors=true && shift ;;
9891
-no-colors) unset colors && shift ;;
9992
-with-compiler) jvm_cp_args="$PSEP$DOTTY_COMP" && shift ;;

project/Build.scala

+20-21
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,6 @@ object Build {
223223
// non-bootstrapped dotty-library that will then take priority over
224224
// the bootstrapped dotty-library on the classpath or sourcepath.
225225
classpathOptions ~= (_.withAutoBoot(false)),
226-
// We still need a Scala bootclasspath equal to the JVM bootclasspath,
227-
// otherwise sbt 0.13 incremental compilation breaks (https://github.com/sbt/sbt/issues/3142)
228-
scalacOptions ++= Seq("-bootclasspath", sys.props("sun.boot.class.path")),
229226

230227
// Enforce that the only Scala 2 classfiles we unpickle come from scala-library
231228
/*
@@ -551,22 +548,22 @@ object Build {
551548
val attList = (dependencyClasspath in Runtime).value
552549
val jars = packageAll.value
553550

554-
// put needed dependencies on classpath:
555-
val path = for {
556-
file <- attList.map(_.data)
557-
path = file.getAbsolutePath
558-
// FIXME: when we snip the cord, this should go bye-bye
559-
if path.contains("scala-library") ||
560-
// FIXME: currently needed for tests referencing scalac internals
561-
path.contains("scala-reflect") ||
562-
// used for tests that compile xml
563-
path.contains("scala-xml") ||
564-
// used for tests that compile dotty
565-
path.contains("scala-asm") ||
566-
// needed for the xsbti interface
567-
path.contains("compiler-interface") ||
568-
path.contains("util-interface")
569-
} yield "-Xbootclasspath/p:" + path
551+
// // put needed dependencies on classpath:
552+
// val path = for {
553+
// file <- attList.map(_.data)
554+
// path = file.getAbsolutePath
555+
// // FIXME: when we snip the cord, this should go bye-bye
556+
// if path.contains("scala-library") ||
557+
// // FIXME: currently needed for tests referencing scalac internals
558+
// path.contains("scala-reflect") ||
559+
// // used for tests that compile xml
560+
// path.contains("scala-xml") ||
561+
// // used for tests that compile dotty
562+
// path.contains("scala-asm") ||
563+
// // needed for the xsbti interface
564+
// path.contains("compiler-interface") ||
565+
// path.contains("util-interface")
566+
// } yield "-Xbootclasspath/p:" + path
570567

571568
val ci_build = // propagate if this is a ci build
572569
sys.props.get("dotty.drone.mem") match {
@@ -586,7 +583,7 @@ object Build {
586583
"-Ddotty.tests.classes.compiler=" + jars("dotty-compiler")
587584
)
588585

589-
jarOpts ::: tuning ::: agentOptions ::: ci_build ::: path.toList
586+
jarOpts ::: tuning ::: agentOptions ::: ci_build
590587
},
591588

592589
testCompilation := testOnlyFiltered("dotty.tools.dotc.*CompilationTests", "--exclude-categories=dotty.SlowTests").evaluated,
@@ -661,7 +658,9 @@ object Build {
661658
)
662659

663660
def runCompilerMain(repl: Boolean = false) = Def.inputTaskDyn {
661+
val attList = (dependencyClasspath in Runtime).value
664662
val jars = packageAll.value
663+
val scalaLib = findLib(attList, "scala-library")
665664
val dottyLib = jars("dotty-library")
666665
val dottyCompiler = jars("dotty-compiler")
667666
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
@@ -677,7 +676,7 @@ object Build {
677676
else if (debugFromTasty) "dotty.tools.dotc.fromtasty.Debug"
678677
else "dotty.tools.dotc.Main"
679678

680-
var extraClasspath = dottyLib
679+
var extraClasspath = s"$scalaLib:$dottyLib"
681680
if ((decompile || printTasty) && !args.contains("-classpath")) extraClasspath += ":."
682681
if (args0.contains("-with-compiler")) {
683682
if (!isDotty.value) {

0 commit comments

Comments
 (0)