Skip to content

Commit

Permalink
Merge pull request #10336 from som-snytt/issue/12257-compile-against-…
Browse files Browse the repository at this point in the history
…rt-jar
  • Loading branch information
SethTisue committed Mar 14, 2023
2 parents c422784 + f69089c commit 15538c7
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/compiler/scala/tools/util/PathResolver.scala
Expand Up @@ -16,12 +16,13 @@ package util

import java.net.URL

import scala.reflect.io.{Directory, File, Path}
import scala.tools.reflect.WrappedProperties.AccessControl
import scala.tools.nsc.{CloseableRegistry, Settings}
import scala.tools.nsc.classpath._
import scala.tools.nsc.util.ClassPath
import scala.reflect.io.{Directory, File, Path}
import scala.util.Properties.isJavaAtLeast
import PartialFunction.condOpt
import scala.tools.nsc.classpath._

// Loosely based on the draft specification at:
// https://wiki.scala-lang.org/display/SIW/Classpath
Expand Down Expand Up @@ -211,22 +212,21 @@ final class PathResolver(settings: Settings, closeableRegistry: CloseableRegistr

private val classPathFactory = new ClassPathFactory(settings, closeableRegistry)

import PathResolver.{ AsLines, Defaults, ppcp }
import PathResolver.{AsLines, Defaults, ppcp}

private def cmdLineOrElse(name: String, alt: String) = {
(commandLineFor(name) match {
case Some("") => None
case x => x
}) getOrElse alt
}
private def cmdLineOrElse(name: String, alt: String) =
commandLineFor(name) match {
case Some("") | None => alt
case Some(x) => x
}

private def commandLineFor(s: String): Option[String] = condOpt(s) {
case "javabootclasspath" => settings.javabootclasspath.value
case "javaextdirs" => settings.javaextdirs.value
case "bootclasspath" => settings.bootclasspath.value
case "extdirs" => settings.extdirs.value
case "classpath" | "cp" => settings.classpath.value
case "sourcepath" => settings.sourcepath.value
case "javabootclasspath" => settings.javabootclasspath.value
case "javaextdirs" => settings.javaextdirs.value
case "bootclasspath" => settings.bootclasspath.value
case "extdirs" => settings.extdirs.value
case "classpath" | "cp" => settings.classpath.value
case "sourcepath" => settings.sourcepath.value
}

/** Calculated values based on any given command line options, falling back on
Expand Down Expand Up @@ -258,8 +258,10 @@ final class PathResolver(settings: Settings, closeableRegistry: CloseableRegistr

// Assemble the elements!
def basis = List[Iterable[ClassPath]](
jrt, // 0. The Java 9+ classpath (backed by the ct.sym or jrt:/ virtual system, if available)
classesInPath(javaBootClassPath), // 1. The Java bootstrap class path.
if (!settings.javabootclasspath.isSetByUser && isJavaAtLeast(9))
jrt // 0. The Java 9+ classpath (backed by the ct.sym or jrt:/ virtual system, if available)
else
classesInPath(javaBootClassPath), // 1. The Java bootstrap class path.
contentsOfDirsInPath(javaExtDirs), // 2. The Java extension class path.
classesInExpandedPath(javaUserClassPath), // 3. The Java application class path.
classesInPath(scalaBootClassPath), // 4. The Scala boot class path.
Expand Down

0 comments on commit 15538c7

Please sign in to comment.