Skip to content

Commit e978b41

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 0f272ff commit e978b41

File tree

3 files changed

+15
-29
lines changed

3 files changed

+15
-29
lines changed

bench/src/main/scala/Benchmarks.scala

Lines changed: 1 addition & 1 deletion
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("-classpath " + libs + ":", "-Xms2G", "-Xmx2G")
4141
.mode(Mode.AverageTime)
4242
.timeUnit(TimeUnit.MILLISECONDS)
4343
.warmupIterations(warmup)

dist/bin/dotc

Lines changed: 1 addition & 8 deletions
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

3332
CompilerMain=dotty.tools.dotc.Main
3433
FromTasty=dotty.tools.dotc.FromTasty
@@ -64,11 +63,7 @@ classpathArgs () {
6463
toolchain+="$DOTTY_LIB$PSEP"
6564
toolchain+="$DOTTY_COMP"
6665

67-
if [[ -n "$bootcp" ]]; then
68-
jvm_cp_args="-Xbootclasspath/a:\"$toolchain\""
69-
else
70-
jvm_cp_args="-classpath \"$toolchain\""
71-
fi
66+
jvm_cp_args="-classpath \"$toolchain\""
7267
}
7368

7469
while [[ $# -gt 0 ]]; do
@@ -85,8 +80,6 @@ case "$1" in
8580
-tasty) PROG_NAME="$FromTasty" && shift ;;
8681
-compile) PROG_NAME="$CompilerMain" && shift ;;
8782
-run) PROG_NAME="$ReplMain" && shift ;;
88-
-bootcp) bootcp=true && shift ;;
89-
-nobootcp) unset bootcp && shift ;;
9083
-colors) colors=true && shift ;;
9184
-no-colors) unset colors && shift ;;
9285

project/Build.scala

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,16 @@ object Build {
514514
}
515515
},
516516
run := Def.inputTaskDyn {
517+
val attList = (dependencyClasspath in Runtime).value
518+
val scalaLib = attList
519+
.map(_.data.getAbsolutePath)
520+
.find(_.contains("scala-library"))
521+
.toList.mkString(":")
517522
val dottyLib = packageAll.value("dotty-library")
518523
val args: Seq[String] = spaceDelimited("<arg>").parsed
519524

520525
val fullArgs = args.span(_ != "-classpath") match {
521-
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: dottyLib :: Nil)
526+
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: s"$dottyLib:$scalaLib" :: Nil)
522527
case (beforeCp, rest) => beforeCp ++ rest
523528
}
524529

@@ -529,11 +534,16 @@ object Build {
529534
dotc := run.evaluated,
530535

531536
repl := Def.inputTaskDyn {
537+
val attList = (dependencyClasspath in Runtime).value
538+
val scalaLib = attList
539+
.map(_.data.getAbsolutePath)
540+
.find(_.contains("scala-library"))
541+
.toList.mkString(":")
532542
val dottyLib = packageAll.value("dotty-library")
533543
val args: Seq[String] = spaceDelimited("<arg>").parsed
534544

535545
val fullArgs = args.span(_ != "-classpath") match {
536-
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: dottyLib :: Nil)
546+
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: s"$dottyLib:$scalaLib" :: Nil)
537547
case (beforeCp, rest) => beforeCp ++ rest
538548
}
539549

@@ -592,25 +602,8 @@ object Build {
592602
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
593603
// packageAll should always be run before tests
594604
javaOptions ++= {
595-
val attList = (dependencyClasspath in Runtime).value
596605
val pA = packageAll.value
597606

598-
// put needed dependencies on classpath:
599-
val path = for {
600-
file <- attList.map(_.data)
601-
path = file.getAbsolutePath
602-
// FIXME: when we snip the cord, this should go bye-bye
603-
if path.contains("scala-library") ||
604-
// FIXME: currently needed for tests referencing scalac internals
605-
path.contains("scala-reflect") ||
606-
// FIXME: should go away when xml literal parsing is removed
607-
path.contains("scala-xml") ||
608-
// used for tests that compile dotty
609-
path.contains("scala-asm") ||
610-
// needed for the xsbti interface
611-
path.contains("sbt-interface")
612-
} yield "-Xbootclasspath/p:" + path
613-
614607
val ci_build = // propagate if this is a ci build
615608
if (sys.props.isDefinedAt(JENKINS_BUILD))
616609
List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: jenkinsMemLimit
@@ -630,7 +623,7 @@ object Build {
630623
"-Ddotty.tests.classes.compiler=" + pA("dotty-compiler")
631624
)
632625

633-
jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
626+
jars ::: tuning ::: agentOptions ::: ci_build
634627
}
635628
)
636629

0 commit comments

Comments
 (0)