Adjust exposed visibility of platform specific implementations.
This commit is contained in:
@@ -20,44 +20,42 @@ internal open class PlatformImplementations {
|
||||
public open fun getMatchResultNamedGroup(matchResult: MatchResult, name: String): MatchGroup? {
|
||||
throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
@InlineExposed
|
||||
val INSTANCE: PlatformImplementations = run {
|
||||
val version = getJavaVersion()
|
||||
try {
|
||||
if (version >= 0x10008)
|
||||
return@run Class.forName("kotlin.internal.JDK8PlatformImplementations").newInstance() as PlatformImplementations
|
||||
} catch (e: ClassNotFoundException) {}
|
||||
|
||||
try {
|
||||
if (version >= 0x10007)
|
||||
return@run Class.forName("kotlin.internal.JDK7PlatformImplementations").newInstance() as PlatformImplementations
|
||||
} catch (e: ClassNotFoundException) {}
|
||||
|
||||
PlatformImplementations()
|
||||
}
|
||||
|
||||
private fun getJavaVersion(): Int {
|
||||
val default = 0x10006
|
||||
val version = System.getProperty("java.version") ?: return default
|
||||
val firstDot = version.indexOf('.')
|
||||
if (firstDot < 0) return default
|
||||
var secondDot = version.indexOf('.', firstDot + 1)
|
||||
if (secondDot < 0) secondDot = version.length
|
||||
|
||||
val firstPart = version.substring(0, firstDot)
|
||||
val secondPart = version.substring(firstDot + 1, secondDot)
|
||||
return try {
|
||||
firstPart.toInt() * 0x10000 + secondPart.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
default
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun platformCloseSuppressed(instance: Closeable, cause: Throwable) = IMPLEMENTATIONS.closeSuppressed(instance, cause)
|
||||
|
||||
|
||||
@JvmField
|
||||
internal val IMPLEMENTATIONS: PlatformImplementations = run {
|
||||
val version = getJavaVersion()
|
||||
try {
|
||||
if (version >= 0x10008)
|
||||
return@run Class.forName("kotlin.internal.JRE8PlatformImplementations").newInstance() as PlatformImplementations
|
||||
} catch (e: ClassNotFoundException) {}
|
||||
|
||||
try {
|
||||
if (version >= 0x10007)
|
||||
return@run Class.forName("kotlin.internal.JRE7PlatformImplementations").newInstance() as PlatformImplementations
|
||||
} catch (e: ClassNotFoundException) {}
|
||||
|
||||
PlatformImplementations()
|
||||
}
|
||||
|
||||
private fun getJavaVersion(): Int {
|
||||
val default = 0x10006
|
||||
val version = System.getProperty("java.version") ?: return default
|
||||
val firstDot = version.indexOf('.')
|
||||
if (firstDot < 0) return default
|
||||
var secondDot = version.indexOf('.', firstDot + 1)
|
||||
if (secondDot < 0) secondDot = version.length
|
||||
|
||||
val firstPart = version.substring(0, firstDot)
|
||||
val secondPart = version.substring(firstDot + 1, secondDot)
|
||||
return try {
|
||||
firstPart.toInt() * 0x10000 + secondPart.toInt()
|
||||
} catch (e: NumberFormatException) {
|
||||
default
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user