diff --git a/libraries/stdlib/jdk7/src/kotlin/internal/JRE7PlatformImplementations.kt b/libraries/stdlib/jdk7/src/kotlin/internal/jdk7/JDK7PlatformImplementations.kt similarity index 75% rename from libraries/stdlib/jdk7/src/kotlin/internal/JRE7PlatformImplementations.kt rename to libraries/stdlib/jdk7/src/kotlin/internal/jdk7/JDK7PlatformImplementations.kt index 136116e4840..5cce9d93f94 100644 --- a/libraries/stdlib/jdk7/src/kotlin/internal/JRE7PlatformImplementations.kt +++ b/libraries/stdlib/jdk7/src/kotlin/internal/jdk7/JDK7PlatformImplementations.kt @@ -14,10 +14,12 @@ * limitations under the License. */ -package kotlin.internal +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") +package kotlin.internal.jdk7 -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal open class JRE7PlatformImplementations : PlatformImplementations() { +import kotlin.internal.PlatformImplementations + +internal open class JDK7PlatformImplementations : PlatformImplementations() { override fun addSuppressed(cause: Throwable, exception: Throwable) = cause.addSuppressed(exception) diff --git a/libraries/stdlib/jdk8/src/kotlin/internal/JRE8PlatformImplementations.kt b/libraries/stdlib/jdk8/src/kotlin/internal/jdk8/JDK8PlatformImplementations.kt similarity index 79% rename from libraries/stdlib/jdk8/src/kotlin/internal/JRE8PlatformImplementations.kt rename to libraries/stdlib/jdk8/src/kotlin/internal/jdk8/JDK8PlatformImplementations.kt index b4a0e12b322..e8f0b59ff5c 100644 --- a/libraries/stdlib/jdk8/src/kotlin/internal/JRE8PlatformImplementations.kt +++ b/libraries/stdlib/jdk8/src/kotlin/internal/jdk8/JDK8PlatformImplementations.kt @@ -14,13 +14,15 @@ * limitations under the License. */ -package kotlin.internal +@file:Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") +package kotlin.internal.jdk8 import java.util.regex.MatchResult import java.util.regex.Matcher +import kotlin.internal.PlatformImplementations +import kotlin.internal.jdk7.JDK7PlatformImplementations -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal open class JRE8PlatformImplementations : JRE7PlatformImplementations() { +internal open class JDK8PlatformImplementations : JDK7PlatformImplementations() { override fun getMatchResultNamedGroup(matchResult: MatchResult, name: String): MatchGroup? { val matcher = matchResult as? Matcher ?: throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.") diff --git a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt index 0c42bbe5409..cdd0c9cab63 100644 --- a/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt +++ b/libraries/stdlib/src/kotlin/internal/PlatformImplementations.kt @@ -19,15 +19,27 @@ internal open class PlatformImplementations { @JvmField internal val IMPLEMENTATIONS: PlatformImplementations = run { val version = getJavaVersion() - try { - if (version >= 0x10008) + if (version >= 0x10008) { + try { + return@run Class.forName("kotlin.internal.jdk8.JDK8PlatformImplementations").newInstance() as PlatformImplementations + } + catch (e: ClassNotFoundException) { } + try { return@run Class.forName("kotlin.internal.JRE8PlatformImplementations").newInstance() as PlatformImplementations - } catch (e: ClassNotFoundException) {} + } + catch (e: ClassNotFoundException) { } + } - try { - if (version >= 0x10007) + if (version >= 0x10007) { + try { + return@run Class.forName("kotlin.internal.jdk7.JDK7PlatformImplementations").newInstance() as PlatformImplementations + } + catch (e: ClassNotFoundException) { } + try { return@run Class.forName("kotlin.internal.JRE7PlatformImplementations").newInstance() as PlatformImplementations - } catch (e: ClassNotFoundException) {} + } + catch (e: ClassNotFoundException) { } + } PlatformImplementations() } @@ -50,4 +62,3 @@ private fun getJavaVersion(): Int { default } } -