Skip to content

Commit 07deb55

Browse files
rochalatgodzik
andauthored
Update presentation-compiler/test/dotty/tools/pc/utils/JRE.scala
Co-authored-by: Tomasz Godzik <[email protected]>
1 parent f5dc97f commit 07deb55

File tree

1 file changed

+3
-12
lines changed
  • presentation-compiler/test/dotty/tools/pc/utils

1 file changed

+3
-12
lines changed

presentation-compiler/test/dotty/tools/pc/utils/JRE.scala

+3-12
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@ package dotty.tools.pc.utils
33
object JRE:
44

55
def getJavaMajorVersion: Int =
6-
val javaVersion = sys.env.get("java.version").filter(!_.isEmpty())
6+
val javaVersion = sys.env.get("java.specification.version").filter(!_.isEmpty())
77

88
javaVersion match
99
case Some(version) if version.startsWith("1.8") => 8
10-
case _ =>
11-
scala.util.Try:
12-
val versionMethod = classOf[Runtime].getMethod("version")
13-
versionMethod.nn.setAccessible(true)
14-
val version = versionMethod.nn.invoke(null)
15-
16-
val majorMethod = version.getClass().getMethod("feature")
17-
majorMethod.nn.setAccessible(true)
18-
val major = majorMethod.nn.invoke(version).asInstanceOf[Int]
19-
major
20-
.getOrElse(8) // Minimal version supported by Scala
10+
case Some(version) => version
11+
case None => 8
2112

2213

0 commit comments

Comments
 (0)