From af443ac046752de5c7bdb0444a4e3bb6c45b05c9 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 2 Feb 2017 19:07:23 +0300 Subject: [PATCH] Search java version in java.specification.version, prepare to that starting from java 9 it will contain only a single component. --- .../stdlib/src/kotlin/internal/PlatformImplementations.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt index 2d9ecb3a142..7819d8b1cb6 100644 --- a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt +++ b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt @@ -40,9 +40,11 @@ internal val IMPLEMENTATIONS: PlatformImplementations = run { private fun getJavaVersion(): Int { val default = 0x10006 - val version = System.getProperty("java.version") ?: return default + val version = System.getProperty("java.specification.version") ?: return default val firstDot = version.indexOf('.') - if (firstDot < 0) return default + if (firstDot < 0) + return try { version.toInt() * 0x10000 } catch (e: NumberFormatException) { default } + var secondDot = version.indexOf('.', firstDot + 1) if (secondDot < 0) secondDot = version.length