Move internal declarations in kotlin-stdlib-jdk7/8 to other packages

- in kotlin-stdlib-jdk7, package kotlin.internal -> kotlin.internal.jdk7
- in kotlin-stdlib-jdk8, package kotlin.internal -> kotlin.internal.jdk8
This commit is contained in:
Alexander Udalov
2017-09-07 18:23:16 +03:00
committed by Ilya Gorbunov
parent 537a0ce315
commit 2a8be2cdb4
3 changed files with 28 additions and 13 deletions
@@ -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)
@@ -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.")
@@ -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
}
}