Introduce kotlin-stdlib-jdk7/8 libraries, deprecate kotlin-stdlib-jre7/8

The idea is to keep all declarations in the same packages from Kotlin's
point of view, but use JvmPackageName annotation to move them to another
JVM package, to avoid the split package problem which is otherwise
unsolvable when using module path on Java 9 (KT-19258).

In this commit, kotlin-stdlib-jre7/8 are moved to kotlin-stdlib-jdk7/8
and in the subsequent commit, -jre7/8 are restored. This is done in
order to make Git recognize this as a file move to preserve history.

Include new stdlib-jdkN artifacts in manifest version tests.
This commit is contained in:
Alexander Udalov
2017-09-07 16:31:19 +03:00
committed by Ilya Gorbunov
parent 2fc3f4d07b
commit e253acd5fd
28 changed files with 69 additions and 36 deletions
@@ -0,0 +1,39 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("UNCHECKED_CAST", "NOTHING_TO_INLINE", "INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("CollectionsJDK8Kt")
@file:kotlin.jvm.JvmPackageName("kotlin.collections.jdk8")
package kotlin.collections
/**
* Returns the value to which the specified key is mapped, or
* [defaultValue] if this map contains no mapping for the key.
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.getOrDefault(key: K, defaultValue: V): V
= (this as Map<K, V>).getOrDefault(key, defaultValue)
/**
* Removes the entry for the specified key only if it is currently
* mapped to the specified value.
*/
@SinceKotlin("1.2")
@kotlin.internal.InlineOnly
public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap<out K, out V>.remove(key: K, value: V): Boolean
= (this as MutableMap<K, V>).remove(key, value)
@@ -0,0 +1,35 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.internal
import java.util.regex.MatchResult
import java.util.regex.Matcher
@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER")
internal open class JRE8PlatformImplementations : JRE7PlatformImplementations() {
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.")
val range = matcher.start(name)..matcher.end(name)-1
return if (range.start >= 0)
MatchGroup(matcher.group(name), range)
else
null
}
}
@@ -0,0 +1,77 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("StreamsKt")
@file:kotlin.jvm.JvmPackageName("kotlin.streams.jdk8")
package kotlin.streams
import java.util.*
import java.util.stream.*
/**
* Creates a [Sequence] instance that wraps the original stream iterating through its elements.
*/
@SinceKotlin("1.2")
public fun <T> Stream<T>.asSequence(): Sequence<T> = Sequence { iterator() }
/**
* Creates a [Sequence] instance that wraps the original stream iterating through its elements.
*/
@SinceKotlin("1.2")
public fun IntStream.asSequence(): Sequence<Int> = Sequence { iterator() }
/**
* Creates a [Sequence] instance that wraps the original stream iterating through its elements.
*/
@SinceKotlin("1.2")
public fun LongStream.asSequence(): Sequence<Long> = Sequence { iterator() }
/**
* Creates a [Sequence] instance that wraps the original stream iterating through its elements.
*/
@SinceKotlin("1.2")
public fun DoubleStream.asSequence(): Sequence<Double> = Sequence { iterator() }
/**
* Creates a sequential [Stream] instance that produces elements from the original sequence.
*/
@SinceKotlin("1.2")
public fun <T> Sequence<T>.asStream(): Stream<T> = StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false)
/**
* Returns a [List] containing all elements produced by this stream.
*/
@SinceKotlin("1.2")
public fun <T> Stream<T>.toList(): List<T> = collect(Collectors.toList<T>())
/**
* Returns a [List] containing all elements produced by this stream.
*/
@SinceKotlin("1.2")
public fun IntStream.toList(): List<Int> = toArray().asList()
/**
* Returns a [List] containing all elements produced by this stream.
*/
@SinceKotlin("1.2")
public fun LongStream.toList(): List<Long> = toArray().asList()
/**
* Returns a [List] containing all elements produced by this stream.
*/
@SinceKotlin("1.2")
public fun DoubleStream.toList(): List<Double> = toArray().asList()
@@ -0,0 +1,34 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
@file:JvmName("RegexExtensionsJDK8Kt")
@file:kotlin.jvm.JvmPackageName("kotlin.text.jdk8")
package kotlin.text
/**
* Returns a named group with the specified [name].
*
* @return An instance of [MatchGroup] if the group with the specified [name] was matched or `null` otherwise.
* @throws [UnsupportedOperationException] if getting named groups isn't supported on the current platform.
*/
@SinceKotlin("1.2")
public operator fun MatchGroupCollection.get(name: String): MatchGroup? {
val namedGroups = this as? MatchNamedGroupCollection ?:
throw UnsupportedOperationException("Retrieving groups by name is not supported on this platform.")
return namedGroups[name]
}