Skip to content

Commit

Permalink
fix buggy Java version check in Scaladoc tool
Browse files Browse the repository at this point in the history
this is a post-2.13.1 regression, due to scala#8663

the bug was that the Java version might be e.g. "14", with
no . characters at all, causing StringIndexOutOfBoundsException

this was caught by the Scala community build
  • Loading branch information
SethTisue committed Apr 21, 2020
1 parent 51233da commit 412346f
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
Expand Up @@ -119,24 +119,17 @@ trait MemberLookup extends base.MemberLookupBase {
}

lazy val defaultJdkUrl = {
if (javaVersion < 11) {
if (isBeforeJava11) {
s"https://docs.oracle.com/javase/$javaVersion/docs/api"
}
else {
s"https://docs.oracle.com/en/java/javase/$javaVersion/docs/api"
}
}

lazy val javaVersion: Int = {
var version = System.getProperty("java.version")
(if (version.startsWith("1.")) {
version.substring(2, 3)
}
else {
val dot = version.indexOf(".")
version.substring(0, dot)
}).toInt
}
lazy val isBeforeJava11: Boolean =
System.getProperty("java.version").split('.')
.headOption.exists(List("1", "9", "10").contains)

override def warnNoLink = !settings.docNoLinkWarnings.value
}

0 comments on commit 412346f

Please sign in to comment.