Skip to content

Commit

Permalink
improvement: Refactor rt jar related code
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Sep 26, 2024
1 parent ec81670 commit 35068a7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions backend/src/main/scala/bloop/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -873,18 +873,19 @@ object Compiler {
case Array("-release", "8") => true
case _ => false
}
val updatedClasspath =
if (needsRtJar) {
val possibleRtJar = inputs.javacBin
.map { binary =>
binary.getParent.resolve("../jre/lib/rt.jar")
val possibleRtJar =
if (needsRtJar)
inputs.javacBin
.flatMap { binary =>
Try {
val javaHome = binary.getParent.getParent
javaHome.resolve("jre/lib/rt.jar")
}.toOption
}
.filter(_.exists)
possibleRtJar match {
case Some(rtJar) => inputs.classpath :+ rtJar
case None => inputs.classpath ++ RtJarCache.create(JavaRuntime.version, logger)
}
} else inputs.classpath
.orElse(RtJarCache.create(JavaRuntime.version, logger))
else None
val updatedClasspath = inputs.classpath ++ possibleRtJar
val classpathVirtual = updatedClasspath.map(path => converter.toVirtualFile(path.underlying))
CompileOptions
.create()
Expand Down

0 comments on commit 35068a7

Please sign in to comment.