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 8983b69
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/scaladoc/scala/tools/nsc/doc/model/MemberLookup.scala
Expand Up @@ -127,16 +127,13 @@ trait MemberLookup extends base.MemberLookupBase {
}
}

lazy val javaVersion: Int = {
var version = System.getProperty("java.version")
(if (version.startsWith("1.")) {
version.substring(2, 3)
lazy val javaVersion: Int =
System.getProperty("java.specification.version").split('.').take(2).map(_.toIntOption) match {
case Array(Some(1), Some(n)) => n // example: 1.8.0_242
case Array(Some(n)) => n // example: 14
case Array(Some(n), _) => n // example: 11.0.7
case _ => 8 // shrug!
}
else {
val dot = version.indexOf(".")
version.substring(0, dot)
}).toInt
}

override def warnNoLink = !settings.docNoLinkWarnings.value
}

0 comments on commit 8983b69

Please sign in to comment.