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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.io.*
|
||||
import java.nio.charset.Charset
|
||||
import java.net.URL
|
||||
import java.util.NoSuchElementException
|
||||
import kotlin.internal.PlatformImplementations
|
||||
import kotlin.internal.*
|
||||
|
||||
|
||||
/** Returns a buffered reader wrapping this Reader, or this Reader itself if it is already buffered. */
|
||||
@@ -159,7 +159,7 @@ public inline fun <T : Closeable, R> T.use(block: (T) -> R): R {
|
||||
} catch (e: Throwable) {
|
||||
closed = true
|
||||
@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
|
||||
PlatformImplementations.INSTANCE.closeSuppressed(this, e)
|
||||
platformCloseSuppressed(this, e)
|
||||
throw e
|
||||
} finally {
|
||||
if (!closed) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package kotlin.text
|
||||
import java.util.*
|
||||
import java.util.regex.Matcher
|
||||
import java.util.regex.Pattern
|
||||
import kotlin.internal.DefaultPlatformImplementations
|
||||
import kotlin.internal.IMPLEMENTATIONS
|
||||
|
||||
private interface FlagEnum {
|
||||
public val value: Int
|
||||
@@ -247,7 +247,7 @@ private class MatcherMatchResult(private val matcher: Matcher, private val input
|
||||
null
|
||||
}
|
||||
override fun get(name: String): MatchGroup? {
|
||||
return DefaultPlatformImplementations.INSTANCE.getMatchResultNamedGroup(matchResult, name)
|
||||
return IMPLEMENTATIONS.getMatchResultNamedGroup(matchResult, name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1583,6 +1583,10 @@ public final class kotlin/concurrent/TimersKt {
|
||||
public static final fun timer (Ljava/lang/String;Z)Ljava/util/Timer;
|
||||
}
|
||||
|
||||
public final class kotlin/internal/PlatformImplementationsKt {
|
||||
public static final fun platformCloseSuppressed (Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
||||
}
|
||||
|
||||
public final class kotlin/io/AccessDeniedException : kotlin/io/FileSystemException {
|
||||
public fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;)V
|
||||
public synthetic fun <init> (Ljava/io/File;Ljava/io/File;Ljava/lang/String;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
||||
@@ -2082,6 +2086,10 @@ public abstract interface class kotlin/text/MatchGroupCollection : java/util/Col
|
||||
public abstract fun get (I)Lkotlin/text/MatchGroup;
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/text/MatchNamedGroupCollection : kotlin/text/MatchGroupCollection {
|
||||
public abstract fun get (Ljava/lang/String;)Lkotlin/text/MatchGroup;
|
||||
}
|
||||
|
||||
public abstract interface class kotlin/text/MatchResult {
|
||||
public abstract fun getDestructured ()Lkotlin/text/MatchResult$Destructured;
|
||||
public abstract fun getGroupValues ()Ljava/util/List;
|
||||
|
||||
Reference in New Issue
Block a user