diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/GenericReplChecker.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/GenericReplChecker.kt index 265f8642f5f..349f8b606b3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/GenericReplChecker.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/repl/GenericReplChecker.kt @@ -56,7 +56,8 @@ open class GenericReplChecker( if (get(JVMConfigurationKeys.JVM_TARGET) == null) { put(JVMConfigurationKeys.JVM_TARGET, System.getProperty(KOTLIN_REPL_JVM_TARGET_PROPERTY)?.let { JvmTarget.fromString(it) } - ?: if (getJavaVersion() >= 0x10008) JvmTarget.JVM_1_8 else JvmTarget.JVM_1_6) + ?: System.getProperty("java.specification.version")?.let { JvmTarget.fromString(it) } + ?: JvmTarget.DEFAULT) } } KotlinCoreEnvironment.createForProduction(disposable, compilerConfiguration, EnvironmentConfigFiles.JVM_CONFIG_FILES) @@ -97,21 +98,3 @@ open class GenericReplChecker( } } } - -// initially taken from libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt -// fixed according to JEP 223 - http://openjdk.java.net/jeps/223 -// TODO: consider to place it to some common place -private fun getJavaVersion(): Int { - val default = 0x10006 - val version = System.getProperty("java.specification.version") ?: return default - val components = version.split('.') - return try { - when (components.size) { - 0 -> default - 1 -> components[0].toInt() * 0x10000 - else -> components[0].toInt() * 0x10000 + components[1].toInt() - } - } catch (e: NumberFormatException) { - default - } -}