Skip to content

Commit 98812e0

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 8c90ae6 commit 98812e0

File tree

3 files changed

+15
-29
lines changed

3 files changed

+15
-29
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 + ":")
40+
.jvmArgsPrepend("-classpath " + libs + ":")
4141
.mode(Mode.AverageTime)
4242
.timeUnit(TimeUnit.MILLISECONDS)
4343
.warmupIterations(warmup)

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

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

+13-20
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,16 @@ object Build {
518518
}
519519
},
520520
run := Def.inputTaskDyn {
521+
val attList = (dependencyClasspath in Runtime).value
522+
val scalaLib = attList
523+
.map(_.data.getAbsolutePath)
524+
.find(_.contains("scala-library"))
525+
.toList.mkString(":")
521526
val dottyLib = packageAll.value("dotty-library")
522527
val args: Seq[String] = spaceDelimited("<arg>").parsed
523528

524529
val fullArgs = args.span(_ != "-classpath") match {
525-
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: dottyLib :: Nil)
530+
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: s"$dottyLib:$scalaLib" :: Nil)
526531
case (beforeCp, rest) => beforeCp ++ rest
527532
}
528533

@@ -533,11 +538,16 @@ object Build {
533538
dotc := run.evaluated,
534539

535540
repl := Def.inputTaskDyn {
541+
val attList = (dependencyClasspath in Runtime).value
542+
val scalaLib = attList
543+
.map(_.data.getAbsolutePath)
544+
.find(_.contains("scala-library"))
545+
.toList.mkString(":")
536546
val dottyLib = packageAll.value("dotty-library")
537547
val args: Seq[String] = spaceDelimited("<arg>").parsed
538548

539549
val fullArgs = args.span(_ != "-classpath") match {
540-
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: dottyLib :: Nil)
550+
case (beforeCp, Nil) => beforeCp ++ ("-classpath" :: s"$dottyLib:$scalaLib" :: Nil)
541551
case (beforeCp, rest) => beforeCp ++ rest
542552
}
543553

@@ -596,25 +606,8 @@ object Build {
596606
// http://grokbase.com/t/gg/simple-build-tool/135ke5y90p/sbt-setting-jvm-boot-paramaters-for-scala
597607
// packageAll should always be run before tests
598608
javaOptions ++= {
599-
val attList = (dependencyClasspath in Runtime).value
600609
val pA = packageAll.value
601610

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

637-
jars ::: tuning ::: agentOptions ::: ci_build ::: path.toList
630+
jars ::: tuning ::: agentOptions ::: ci_build
638631
}
639632
)
640633

0 commit comments

Comments
 (0)