From 811566bbe0cc05ac310886e29db9dbedd49cc2e6 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 13 Feb 2019 17:32:22 +0300 Subject: [PATCH] Drop obsolete artifacts kotlin-stdlib-jre7/8 --- build.gradle.kts | 2 - buildSrc/src/main/kotlin/dependencies.kt | 2 - libraries/stdlib/jre7/build.gradle | 71 --------- .../stdlib/jre7/src/kotlin/AutoCloseable.kt | 62 -------- .../internal/JRE7PlatformImplementations.kt | 24 --- .../test/TryWithResourcesAutoCloseableTest.kt | 128 ---------------- .../test/TryWithResourcesCloseableTest.kt | 127 --------------- libraries/stdlib/jre8/build.gradle | 73 --------- .../src/kotlin/collections/Collections.kt | 40 ----- .../internal/JRE8PlatformImplementations.kt | 35 ----- .../stdlib/jre8/src/kotlin/streams/Streams.kt | 75 --------- .../jre8/src/kotlin/text/RegexExtensions.kt | 32 ---- .../jre8/test/collections/CollectionTest.kt | 48 ------ .../jre8/test/collections/IterableTest.kt | 53 ------- .../stdlib/jre8/test/collections/ListTest.kt | 35 ----- .../stdlib/jre8/test/collections/MapTest.kt | 144 ------------------ .../jre8/test/collections/StreamsTest.kt | 70 --------- libraries/stdlib/jre8/test/text/RegexTest.kt | 42 ----- .../binary-compatibility-validator/ReadMe.md | 2 +- .../build.gradle | 2 - .../kotlin-stdlib-jre7.txt | 4 - .../kotlin-stdlib-jre8.txt | 16 -- .../RuntimePublicAPITest.kt | 8 - settings.gradle | 4 - 24 files changed, 1 insertion(+), 1098 deletions(-) delete mode 100644 libraries/stdlib/jre7/build.gradle delete mode 100644 libraries/stdlib/jre7/src/kotlin/AutoCloseable.kt delete mode 100644 libraries/stdlib/jre7/src/kotlin/internal/JRE7PlatformImplementations.kt delete mode 100644 libraries/stdlib/jre7/test/TryWithResourcesAutoCloseableTest.kt delete mode 100644 libraries/stdlib/jre7/test/TryWithResourcesCloseableTest.kt delete mode 100644 libraries/stdlib/jre8/build.gradle delete mode 100644 libraries/stdlib/jre8/src/kotlin/collections/Collections.kt delete mode 100644 libraries/stdlib/jre8/src/kotlin/internal/JRE8PlatformImplementations.kt delete mode 100644 libraries/stdlib/jre8/src/kotlin/streams/Streams.kt delete mode 100644 libraries/stdlib/jre8/src/kotlin/text/RegexExtensions.kt delete mode 100644 libraries/stdlib/jre8/test/collections/CollectionTest.kt delete mode 100644 libraries/stdlib/jre8/test/collections/IterableTest.kt delete mode 100644 libraries/stdlib/jre8/test/collections/ListTest.kt delete mode 100644 libraries/stdlib/jre8/test/collections/MapTest.kt delete mode 100644 libraries/stdlib/jre8/test/collections/StreamsTest.kt delete mode 100644 libraries/stdlib/jre8/test/text/RegexTest.kt delete mode 100644 libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre7.txt delete mode 100644 libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre8.txt diff --git a/build.gradle.kts b/build.gradle.kts index 11fe19dfc96..b050d05598f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -443,8 +443,6 @@ tasks { create("coreLibsTest") { (coreLibProjects + listOf( - ":kotlin-stdlib-jre7", - ":kotlin-stdlib-jre8", ":kotlin-stdlib:samples", ":kotlin-test:kotlin-test-js:kotlin-test-js-it", ":kotlinx-metadata-jvm", diff --git a/buildSrc/src/main/kotlin/dependencies.kt b/buildSrc/src/main/kotlin/dependencies.kt index 2598a2b7a2f..a4c2d9d2b0d 100644 --- a/buildSrc/src/main/kotlin/dependencies.kt +++ b/buildSrc/src/main/kotlin/dependencies.kt @@ -144,8 +144,6 @@ val testDistProjects = listOf( ":kotlin-compiler", ":kotlin-script-runtime", ":kotlin-stdlib", - ":kotlin-stdlib-jre7", - ":kotlin-stdlib-jre8", ":kotlin-stdlib-jdk7", ":kotlin-stdlib-jdk8", ":kotlin-stdlib-js", diff --git a/libraries/stdlib/jre7/build.gradle b/libraries/stdlib/jre7/build.gradle deleted file mode 100644 index c78ee411a7b..00000000000 --- a/libraries/stdlib/jre7/build.gradle +++ /dev/null @@ -1,71 +0,0 @@ -description = 'Kotlin Standard Library JRE 7 extension (deprecated)' - -apply plugin: 'kotlin' -apply plugin: 'pill-configurable' - -configureJvm6Project(project) -configureDist(project) -ext.javaHome = JDK_17 - -pill { - importAsLibrary = true -} - -dependencies { - compile project(':kotlin-stdlib') - testCompile project(':kotlin-test:kotlin-test-junit') -} - -sourceSets { - main { - kotlin { - srcDir 'src' - } - } - test { - kotlin { - srcDir 'test' - } - } -} - -jar { - manifestAttributes(manifest, project, 'Main') -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -task distForTest(type: Copy) { - rename "-${java.util.regex.Pattern.quote(version)}", '' - from jar - into distDir -} - -dist { - dependsOn(distForTest) -} - - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions.jdkHome = JDK_17 -} - -compileKotlin { - kotlinOptions.freeCompilerArgs = [ - "-Xallow-kotlin-package", - "-Xmultifile-parts-inherit", - "-Xnormalize-constructor-calls=enable", - "-module-name", project.name - ] -} - -compileTestKotlin { - kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xmulti-platform", "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes"] -} - -test { - executable = "$JDK_17/bin/java" -} diff --git a/libraries/stdlib/jre7/src/kotlin/AutoCloseable.kt b/libraries/stdlib/jre7/src/kotlin/AutoCloseable.kt deleted file mode 100644 index cf47b37dea9..00000000000 --- a/libraries/stdlib/jre7/src/kotlin/AutoCloseable.kt +++ /dev/null @@ -1,62 +0,0 @@ -/* - * 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:JvmName("AutoCloseableKt") -package kotlin - -/** - * Executes the given [block] function on this resource and then closes it down correctly whether an exception - * is thrown or not. - * - * In case if the resource is being closed due to an exception occurred in [block], and the closing also fails with an exception, - * the latter is added to the [suppressed][java.lang.Throwable.addSuppressed] exceptions of the former. - * - * @param block a function to process this [AutoCloseable] resource. - * @return the result of [block] function invoked on this resource. - */ -@SinceKotlin("1.1") -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -@kotlin.internal.InlineOnly -public inline fun T.use(block: (T) -> R): R { - var exception: Throwable? = null - try { - return block(this) - } catch (e: Throwable) { - exception = e - throw e - } finally { - this.closeFinally(exception) - } -} - -/** - * Closes this [AutoCloseable], suppressing possible exception or error thrown by [AutoCloseable.close] function when - * it's being closed due to some other [cause] exception occurred. - * - * The suppressed exception is added to the list of suppressed exceptions of [cause] exception. - */ -@SinceKotlin("1.1") -@PublishedApi -internal fun AutoCloseable?.closeFinally(cause: Throwable?) = when { - this == null -> {} - cause == null -> close() - else -> - try { - close() - } catch (closeException: Throwable) { - cause.addSuppressed(closeException) - } -} diff --git a/libraries/stdlib/jre7/src/kotlin/internal/JRE7PlatformImplementations.kt b/libraries/stdlib/jre7/src/kotlin/internal/JRE7PlatformImplementations.kt deleted file mode 100644 index 136116e4840..00000000000 --- a/libraries/stdlib/jre7/src/kotlin/internal/JRE7PlatformImplementations.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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 - -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER", "CANNOT_OVERRIDE_INVISIBLE_MEMBER") -internal open class JRE7PlatformImplementations : PlatformImplementations() { - - override fun addSuppressed(cause: Throwable, exception: Throwable) = cause.addSuppressed(exception) - -} diff --git a/libraries/stdlib/jre7/test/TryWithResourcesAutoCloseableTest.kt b/libraries/stdlib/jre7/test/TryWithResourcesAutoCloseableTest.kt deleted file mode 100644 index 9d60ffd7f56..00000000000 --- a/libraries/stdlib/jre7/test/TryWithResourcesAutoCloseableTest.kt +++ /dev/null @@ -1,128 +0,0 @@ -/* - * 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.jdk7.test - -import java.io.* -import org.junit.Test -import java.util.* -import kotlin.test.* - -class TryWithResourcesAutoCloseableTest { - - @Suppress("HasPlatformType") fun platformNull() = Collections.singletonList(null as T).first() - - class Resource(val faultyClose: Boolean = false) : AutoCloseable { - - var isClosed = false - private set - - override fun close() { - if (faultyClose) - throw IOException("Close failed") - isClosed = true - } - } - - - @Test fun success() { - val resource = Resource() - val result = resource.use { "ok" } - assertEquals("ok", result) - assertTrue(resource.isClosed) - } - - @Test fun closeFails() { - val e = assertFails { - Resource(faultyClose = true).use { "" } - } - assertTrue(e is IOException) - } - - @Test fun opFailsCloseSuccess() { - val e = assertFails { - Resource().use { error("op fail") } - } - assertTrue(e is IllegalStateException) - assertTrue(e.suppressed.isEmpty()) - } - - @Test fun opFailsCloseFails() { - val e = assertFails { - Resource(faultyClose = true).use { error("op fail") } - } - assertTrue(e is IllegalStateException) - assertTrue(e.suppressed.single() is IOException) - } - - @Test fun opFailsCloseFailsTwice() { - val e = assertFails { - Resource(faultyClose = true).use { _ -> - Resource(faultyClose = true).use { _ -> - error("op fail") - } - } - } - assertTrue(e is IllegalStateException) - val suppressed = e.suppressed - assertEquals(2, suppressed.size) - assertTrue(suppressed.all { it is IOException }) - } - - @Test fun nonLocalReturnInBlock() { - fun Resource.operation(nonLocal: Boolean): String { - return use { if (nonLocal) return "nonLocal" else "local" } - } - - Resource().let { resource -> - val result = resource.operation(nonLocal = false) - assertEquals("local", result) - assertTrue(resource.isClosed) - } - - Resource().let { resource -> - val result = resource.operation(nonLocal = true) - assertEquals("nonLocal", result) - assertTrue(resource.isClosed) - } - } - - - @Test fun nullableResourceSuccess() { - val resource: Resource? = null - val result = resource.use { "ok" } - assertEquals("ok", result) - } - - @Test fun nullableResourceOpFails() { - val resource: Resource? = null - val e = assertFails { - resource.use { requireNotNull(it) } - } - assertTrue(e is IllegalArgumentException) - assertTrue(e.suppressed.isEmpty()) - } - - @Test fun platformResourceOpFails() { - val resource = platformNull() - val e = assertFails { - resource.use { requireNotNull(it) } - } - assertTrue(e is IllegalArgumentException) - assertTrue(e.suppressed.isEmpty()) - } - -} diff --git a/libraries/stdlib/jre7/test/TryWithResourcesCloseableTest.kt b/libraries/stdlib/jre7/test/TryWithResourcesCloseableTest.kt deleted file mode 100644 index 679137f20bd..00000000000 --- a/libraries/stdlib/jre7/test/TryWithResourcesCloseableTest.kt +++ /dev/null @@ -1,127 +0,0 @@ -/* - * 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 test.jdk7 - -import org.junit.Ignore -import java.io.* -import org.junit.Test -import java.util.* -import kotlin.test.* - -class TryWithResourcesCloseableTest { - - @Suppress("HasPlatformType") fun platformNull() = Collections.singletonList(null as T).first() - - class Resource(val faultyClose: Boolean = false) : Closeable { - - var isClosed = false - private set - - override fun close() { - if (faultyClose) - throw IOException("Close failed") - isClosed = true - } - } - - @Test fun success() { - val resource = Resource() - val result = resource.use { "ok" } - assertEquals("ok", result) - assertTrue(resource.isClosed) - } - - @Test fun closeFails() { - val e = assertFails { - Resource(faultyClose = true).use { "" } - } - assertTrue(e is IOException) - } - - @Test fun opFailsCloseSuccess() { - val e = assertFails { - Resource().use { error("op fail") } - } - assertTrue(e is IllegalStateException) - assertTrue(e.suppressed.isEmpty()) - } - - @Test fun opFailsCloseFails() { - val e = assertFails { - Resource(faultyClose = true).use { error("op fail") } - } - assertTrue(e is IllegalStateException) - assertTrue(e.suppressed.single() is IOException) - } - - @Test fun opFailsCloseFailsTwice() { - val e = assertFails { - Resource(faultyClose = true).use { _ -> - Resource(faultyClose = true).use { _ -> - error("op fail") - } - } - } - assertTrue(e is IllegalStateException) - val suppressed = e.suppressed - assertEquals(2, suppressed.size) - assertTrue(suppressed.all { it is IOException }) - } - - @Test fun nonLocalReturnInBlock() { - fun Resource.operation(nonLocal: Boolean): String { - return use { if (nonLocal) return "nonLocal" else "local" } - } - - Resource().let { resource -> - val result = resource.operation(nonLocal = false) - assertEquals("local", result) - assertTrue(resource.isClosed) - } - - Resource().let { resource -> - val result = resource.operation(nonLocal = true) - assertEquals("nonLocal", result) - assertTrue(resource.isClosed) - } - - } - - @Test fun nullableResourceSuccess() { - val resource: Resource? = null - val result = resource.use { "ok" } - assertEquals("ok", result) - } - - @Test fun nullableResourceOpFails() { - val resource: Resource? = null - val e = assertFails { - resource.use { requireNotNull(it) } - } - assertTrue(e is IllegalArgumentException) - assertTrue(e.suppressed.isEmpty()) - } - - @Test fun platformResourceOpFails() { - val resource = platformNull() - val e = assertFails { - resource.use { requireNotNull(it) } - } - assertTrue(e is IllegalArgumentException) - assertTrue(e.suppressed.isEmpty()) - } -} diff --git a/libraries/stdlib/jre8/build.gradle b/libraries/stdlib/jre8/build.gradle deleted file mode 100644 index d534c3653fc..00000000000 --- a/libraries/stdlib/jre8/build.gradle +++ /dev/null @@ -1,73 +0,0 @@ -description = 'Kotlin Standard Library JRE 8 extension (deprecated)' - -apply plugin: 'kotlin' -apply plugin: 'pill-configurable' - -configureJvm6Project(project) -configureDist(project) -ext.javaHome = JDK_18 -ext.jvmTarget = "1.8" - -pill { - importAsLibrary = true -} - -dependencies { - compile project(':kotlin-stdlib') - compile project(':kotlin-stdlib-jre7') - testCompile project(':kotlin-test:kotlin-test-junit') -} - -sourceSets { - main { - kotlin { - srcDir 'src' - } - } - test { - kotlin { - srcDir 'test' - } - } -} - -jar { - manifestAttributes(manifest, project, 'Main') -} - -artifacts { - archives sourcesJar - archives javadocJar -} - -task distForTest(type: Copy) { - rename "-${java.util.regex.Pattern.quote(version)}", '' - from jar - into distDir -} - -dist { - dependsOn(distForTest) -} - -tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile) { - kotlinOptions.jdkHome = JDK_18 - kotlinOptions.jvmTarget = 1.8 -} - -compileKotlin { - kotlinOptions.freeCompilerArgs = [ - "-Xallow-kotlin-package", - "-Xmultifile-parts-inherit", - "-Xnormalize-constructor-calls=enable", - "-module-name", project.name - ] -} - -compileTestKotlin { - kotlinOptions.freeCompilerArgs = ["-Xallow-kotlin-package", "-Xnormalize-constructor-calls=enable", "-Xmulti-platform", "-Xuse-experimental=kotlin.ExperimentalUnsignedTypes"] -} - -test { - executable = "$JDK_18/bin/java" -} diff --git a/libraries/stdlib/jre8/src/kotlin/collections/Collections.kt b/libraries/stdlib/jre8/src/kotlin/collections/Collections.kt deleted file mode 100644 index 38870e5c550..00000000000 --- a/libraries/stdlib/jre8/src/kotlin/collections/Collections.kt +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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") -@file:JvmName("CollectionsJRE8Kt") -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.1") -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -@kotlin.internal.InlineOnly -public inline fun <@kotlin.internal.OnlyInputTypes K, V> Map.getOrDefault(key: K, defaultValue: V): V - = (this as Map).getOrDefault(key, defaultValue) - - -/** - * Removes the entry for the specified key only if it is currently - * mapped to the specified value. - */ -@SinceKotlin("1.1") -@Suppress("INVISIBLE_REFERENCE", "INVISIBLE_MEMBER") -@kotlin.internal.InlineOnly -public inline fun <@kotlin.internal.OnlyInputTypes K, @kotlin.internal.OnlyInputTypes V> MutableMap.remove(key: K, value: V): Boolean - = (this as MutableMap).remove(key, value) diff --git a/libraries/stdlib/jre8/src/kotlin/internal/JRE8PlatformImplementations.kt b/libraries/stdlib/jre8/src/kotlin/internal/JRE8PlatformImplementations.kt deleted file mode 100644 index b4a0e12b322..00000000000 --- a/libraries/stdlib/jre8/src/kotlin/internal/JRE8PlatformImplementations.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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 - } - -} diff --git a/libraries/stdlib/jre8/src/kotlin/streams/Streams.kt b/libraries/stdlib/jre8/src/kotlin/streams/Streams.kt deleted file mode 100644 index 28327fc7951..00000000000 --- a/libraries/stdlib/jre8/src/kotlin/streams/Streams.kt +++ /dev/null @@ -1,75 +0,0 @@ -/* - * 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:JvmName("StreamsKt") -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.1") -public fun Stream.asSequence(): Sequence = Sequence { iterator() } - -/** - * Creates a [Sequence] instance that wraps the original stream iterating through its elements. - */ -@SinceKotlin("1.1") -public fun IntStream.asSequence(): Sequence = Sequence { iterator() } - -/** - * Creates a [Sequence] instance that wraps the original stream iterating through its elements. - */ -@SinceKotlin("1.1") -public fun LongStream.asSequence(): Sequence = Sequence { iterator() } - -/** - * Creates a [Sequence] instance that wraps the original stream iterating through its elements. - */ -@SinceKotlin("1.1") -public fun DoubleStream.asSequence(): Sequence = Sequence { iterator() } - -/** - * Creates a sequential [Stream] instance that produces elements from the original sequence. - */ -@SinceKotlin("1.1") -public fun Sequence.asStream(): Stream = StreamSupport.stream({ Spliterators.spliteratorUnknownSize(iterator(), Spliterator.ORDERED) }, Spliterator.ORDERED, false) - -/** - * Returns a [List] containing all elements produced by this stream. - */ -@SinceKotlin("1.1") -public fun Stream.toList(): List = collect(Collectors.toList()) - -/** - * Returns a [List] containing all elements produced by this stream. - */ -@SinceKotlin("1.1") -public fun IntStream.toList(): List = toArray().asList() - -/** - * Returns a [List] containing all elements produced by this stream. - */ -@SinceKotlin("1.1") -public fun LongStream.toList(): List = toArray().asList() - -/** - * Returns a [List] containing all elements produced by this stream. - */ -@SinceKotlin("1.1") -public fun DoubleStream.toList(): List = toArray().asList() diff --git a/libraries/stdlib/jre8/src/kotlin/text/RegexExtensions.kt b/libraries/stdlib/jre8/src/kotlin/text/RegexExtensions.kt deleted file mode 100644 index 098ee02b9f7..00000000000 --- a/libraries/stdlib/jre8/src/kotlin/text/RegexExtensions.kt +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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:JvmName("RegexExtensionsJRE8Kt") -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.1") -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] -} diff --git a/libraries/stdlib/jre8/test/collections/CollectionTest.kt b/libraries/stdlib/jre8/test/collections/CollectionTest.kt deleted file mode 100644 index ef79925ef4c..00000000000 --- a/libraries/stdlib/jre8/test/collections/CollectionTest.kt +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.jdk8.collections.test - -import org.junit.Test -import kotlin.test.* -import java.util.function.Predicate -import java.util.stream.Collectors -import kotlin.streams.* - -class CollectionTest { - - val data = listOf("abc", "fo", "baar") - - @Test fun stream() { - assertEquals( - data.flatMap { it.asIterable() }, - data.stream() - .flatMap { it.chars().boxed().map { it.toChar() } } - .collect(Collectors.toList())) - - assertEquals(data, data.parallelStream().toList()) - } - - - @Test fun removeIf() { - val coll: MutableCollection = data.toMutableList() - assertTrue(coll.removeIf { it.length < 3 }) - assertEquals(listOf("abc", "baar"), coll as Collection) - assertFalse(coll.removeIf(Predicate { it.length > 4 })) - } - - -} diff --git a/libraries/stdlib/jre8/test/collections/IterableTest.kt b/libraries/stdlib/jre8/test/collections/IterableTest.kt deleted file mode 100644 index d1117205949..00000000000 --- a/libraries/stdlib/jre8/test/collections/IterableTest.kt +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.jdk8.collections.test - -import org.junit.Test -import kotlin.test.* -import java.util.function.* - -class IterableTest { - - val data = listOf("foo", "bar") - val iterable = Iterable { data.iterator() } - - @Test fun spliterator() { - val spliterator = iterable.spliterator() - - assertEquals(-1, spliterator.exactSizeIfKnown) - val expected = data.toMutableList() - spliterator.forEachRemaining { - assertEquals(expected.removeAt(0), it) - } - } - - @Test fun forEach() { - val expected = data.toMutableList() - iterable.forEach(Consumer { - assertEquals(expected.removeAt(0), it) - }) - } - - @Test fun forEachRemaining() { - val expected = data.toMutableList() - val iterator = iterable.iterator() - iterator.forEachRemaining(Consumer { - assertEquals(expected.removeAt(0), it) - }) - } - -} diff --git a/libraries/stdlib/jre8/test/collections/ListTest.kt b/libraries/stdlib/jre8/test/collections/ListTest.kt deleted file mode 100644 index 6672287e3f0..00000000000 --- a/libraries/stdlib/jre8/test/collections/ListTest.kt +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.jdk8.collections.test - -import org.junit.Test -import kotlin.test.* -import java.util.function.UnaryOperator - -class ListTest { - - @Test fun replaceAll() { - val list = mutableListOf("ab", "cde", "x") - list.replaceAll { it.length.toString() } - - val expected = listOf("2", "3", "1") - assertEquals(expected, list) - - list.replaceAll(UnaryOperator.identity()) - assertEquals(expected, list) - } -} diff --git a/libraries/stdlib/jre8/test/collections/MapTest.kt b/libraries/stdlib/jre8/test/collections/MapTest.kt deleted file mode 100644 index 6f1d49206af..00000000000 --- a/libraries/stdlib/jre8/test/collections/MapTest.kt +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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.jdk8.collections.test - -import org.junit.Test -import java.util.function.BiFunction -import kotlin.test.* -import kotlin.jdk8.collections.* - -class MapTest { - - @Test fun getOrDefault() { - val map = mapOf("x" to 1, "z" to null) - assertEquals(1, map.getOrDefault("x", 0)) - assertEquals(0, map.getOrDefault("y", 0)) - assertEquals(null, map.getOrDefault("z", 0)) - assertEquals(null, map.getOrDefault("y" as CharSequence, null)) - - val nonNullMap = mapOf("x" to 1) - assertEquals(null, nonNullMap.getOrDefault("y" as CharSequence, null)) // should pass - assertEquals("none", nonNullMap.getOrDefault("y" as CharSequence, "none")) // should not compile - } - - @Test fun forEach() { - val map = mapOf("k" to "v") - map.forEach { k, v -> - assertEquals("k", k) - assertEquals("v", v) - } - map.forEach { - assertEquals("k", it.key) - assertEquals("v", it.value) - } - } - - @Test fun replaceAll() { - val map: MutableMap = mutableMapOf("a" to "b", "c" to "d") - - map.replaceAll { k, v -> k + v } - assertEquals(mapOf("a" to "ab", "c" to "cd"), map) - - val operator = BiFunction { k, v -> k.toString() + v.toString() } - map.replaceAll(operator) - assertEquals(mapOf("a" to "aab", "c" to "ccd"), map) - } - - @Test fun putIfAbsent() { - val map = mutableMapOf(1 to "a") - - assertEquals("a", map.putIfAbsent(1, "b")) - assertEquals("a", map[1]) - - assertEquals(null, map.putIfAbsent(2, "b")) - assertEquals("b", map[2]) - } - - - @Test fun removeKeyValue() { - val map = mutableMapOf(1 to "a") - - assertEquals(false, map.remove(1 as Number, null as Any?)) // requires import - assertEquals(true, map.remove(1, "a")) - } - - @Test fun replace() { - val map = mutableMapOf(1 to "a", 2 to null) - assertTrue(map.replace(2, null, "x")) - assertEquals("x", map[2]) - - assertFalse(map.replace(2, null, "x")) - - assertEquals("a", map.replace(1, "b")) - assertEquals(null, map.replace(3, "c")) - - } - - @Test fun computeIfAbsent() { - val map = mutableMapOf(2 to "x") - assertEquals("x", map.computeIfAbsent(2) { it.toString() }) - assertEquals("3", map.computeIfAbsent(3) { it.toString() }) - // prohibited: map.computeIfAbsent(0) { null } - - val map2 = mutableMapOf(2 to "x", 3 to null) - assertEquals("x", map2.computeIfAbsent(2) { it.toString() }) - assertEquals("3", map2.computeIfAbsent(3) { it.toString() }) - assertEquals(null, map2.computeIfAbsent(0) { null }) - assertFalse(0 in map2) - } - - @Test fun computeIfPresent() { - val map = mutableMapOf(2 to "x") - assertEquals("2x", map.computeIfPresent(2) { k, v -> k.toString() + v }) - assertEquals(null, map.computeIfPresent(3) { k, v -> k.toString() + v }) - assertEquals(null, map.computeIfPresent(2) { _, _ -> null }) - assertFalse(2 in map) - - val map2 = mutableMapOf(2 to "x") - assertEquals("2x", map2.computeIfPresent(2) { k, v -> k.toString() + v }) - assertEquals(null, map2.computeIfPresent(3) { k, v -> k.toString() + v }) - assertEquals(null, map2.computeIfPresent(2) { _, _ -> null }) - assertFalse(2 in map2) - } - - @Test fun compute() { - val map = mutableMapOf(2 to "x") - assertEquals("2x", map.compute(2) { k, v -> k.toString() + v }) - assertEquals(null, map.compute(2) { _, _ -> null }) - assertFalse { 2 in map } - assertEquals("1null", map.compute(1) { k, v -> k.toString() + v }) - } - - @Test fun merge() { - val map = mutableMapOf(2 to "x") - assertEquals("y", map.merge(3, "y") { _, _ -> null }) - assertEquals(null, map.merge(3, "z") { old, new -> - assertEquals("y", old) - assertEquals("z", new) - null - }) - assertFalse(3 in map) - - // fails due to KT-12144 - val map2 = mutableMapOf(1 to null) - // new value must be V&Any - assertEquals("e", map2.merge(1, "e") { old, new -> (old.length + new.length).toString() ?: null }) - assertEquals("3", map2.merge(1, "fg") { old, new -> (old.length + new.length).toString() ?: null }) - assertEquals(null, map2.merge(1, "3") { _, _ -> null }) - assertFalse(1 in map) - } -} diff --git a/libraries/stdlib/jre8/test/collections/StreamsTest.kt b/libraries/stdlib/jre8/test/collections/StreamsTest.kt deleted file mode 100644 index 86a122e9151..00000000000 --- a/libraries/stdlib/jre8/test/collections/StreamsTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.jdk8.streams.test - -import kotlin.streams.* -import org.junit.Test -import java.util.stream.* -import kotlin.test.* - -class StreamsTest { - - @Test fun toList() { - val data = arrayOf(1, 2L, 1.23, null) - val streamBuilder = { Stream.of(*data) } - - assertEquals(data.asList(), streamBuilder().toList()) - assertEquals(listOf(1), streamBuilder().filter { it is Int }.mapToInt { it as Int }.toList()) - assertEquals(listOf(2L), streamBuilder().filter { it is Long }.mapToLong { it as Long }.toList()) - assertEquals(listOf(1.23), streamBuilder().filter { it is Double }.mapToDouble { it as Double }.toList()) - } - - - @Test fun asSequence() { - val data = arrayOf(1, 2L, 1.23, null) - - fun assertSequenceContent(expected: List, actual: Sequence) { - assertEquals(expected, actual.toList()) - assertFailsWith ("Second iteration fails") { actual.toList() } - - } - - assertSequenceContent(data.asList(), Stream.of(*data).asSequence()) - assertSequenceContent(listOf(1, 2), IntStream.of(1, 2).asSequence()) - assertSequenceContent(listOf(1L, 2L), LongStream.of(1L, 2L).asSequence()) - assertSequenceContent(listOf(1.0, 2.0), DoubleStream.of(1.0, 2.0).asSequence()) - } - - @Test fun asStream() { - val sequence = generateSequence(0) { it -> it * it + 1 } - val stream = sequence.asStream() - val expected = Stream.iterate(0) { it -> it * it + 1 } - - assertEquals(expected.limit(7).toList(), stream.limit(7).toList()) - } - - @Test fun asParallelStream() { - val sequence = generateSequence(0) { it + 2 } // even numbers - val stream = sequence.asStream().parallel().map { it / 2 } - - val n = 100000 - val expected = (0 until n).toList() - - assertEquals(expected, stream.limit(n.toLong()).toList()) - } - -} diff --git a/libraries/stdlib/jre8/test/text/RegexTest.kt b/libraries/stdlib/jre8/test/text/RegexTest.kt deleted file mode 100644 index f3d13fc556a..00000000000 --- a/libraries/stdlib/jre8/test/text/RegexTest.kt +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.text.test - -import org.junit.Test -import kotlin.test.* - -class RegexTest { - @Test fun namedGroups() { - val input = "1a 2b 3c" - val regex = "(?\\d)(?\\w)".toRegex() - - val matches = regex.findAll(input).toList() - assertTrue(matches.all { it.groups.size == 3 }) - val m1 = matches[0] - - assertEquals("1", m1.groups["num"]?.value) - assertEquals(0..0, m1.groups["num"]?.range) - assertEquals("a", m1.groups["liter"]?.value) - assertEquals(1..1, m1.groups["liter"]?.range) - - val m2 = matches[1] - assertEquals("2", m2.groups["num"]?.value) - assertEquals(3..3, m2.groups["num"]?.range) - assertEquals("b", m2.groups["liter"]?.value) - assertEquals(4..4, m2.groups["liter"]?.range) - } -} diff --git a/libraries/tools/binary-compatibility-validator/ReadMe.md b/libraries/tools/binary-compatibility-validator/ReadMe.md index 51fc5e9a055..0889d74b9a3 100644 --- a/libraries/tools/binary-compatibility-validator/ReadMe.md +++ b/libraries/tools/binary-compatibility-validator/ReadMe.md @@ -7,7 +7,7 @@ and ensure that the public binary API wasn't changed in a way that make this cha Compile and run tests. `CasesPublicAPITest` verifies the tool itself, and `RuntimePublicAPITest` dumps the public API of `kotlin-stdlib`, -`kotlin-stdlib-jdk7/8`, `kotlin-stdlib-jre7/8` and `kotlin-reflect` jars, +`kotlin-stdlib-jdk7/8`, and `kotlin-reflect` jars, which must be built beforehand with gradle. Use `clean assemble` tasks, since the incremental compilation currently doesn't produce all the required output. diff --git a/libraries/tools/binary-compatibility-validator/build.gradle b/libraries/tools/binary-compatibility-validator/build.gradle index 5dfbd6e8b93..4bc6170d2be 100644 --- a/libraries/tools/binary-compatibility-validator/build.gradle +++ b/libraries/tools/binary-compatibility-validator/build.gradle @@ -16,8 +16,6 @@ dependencies { testCompile project(':kotlin-test:kotlin-test-junit') testArtifacts project(':kotlin-stdlib') - testArtifacts project(':kotlin-stdlib-jre7') - testArtifacts project(':kotlin-stdlib-jre8') testArtifacts project(':kotlin-stdlib-jdk7') testArtifacts project(':kotlin-stdlib-jdk8') testArtifacts project(':kotlin-reflect') diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre7.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre7.txt deleted file mode 100644 index 5e9eb275b06..00000000000 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre7.txt +++ /dev/null @@ -1,4 +0,0 @@ -public final class kotlin/AutoCloseableKt { - public static final fun closeFinally (Ljava/lang/AutoCloseable;Ljava/lang/Throwable;)V -} - diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre8.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre8.txt deleted file mode 100644 index cb60b69937b..00000000000 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-jre8.txt +++ /dev/null @@ -1,16 +0,0 @@ -public final class kotlin/streams/StreamsKt { - public static final fun asSequence (Ljava/util/stream/DoubleStream;)Lkotlin/sequences/Sequence; - public static final fun asSequence (Ljava/util/stream/IntStream;)Lkotlin/sequences/Sequence; - public static final fun asSequence (Ljava/util/stream/LongStream;)Lkotlin/sequences/Sequence; - public static final fun asSequence (Ljava/util/stream/Stream;)Lkotlin/sequences/Sequence; - public static final fun asStream (Lkotlin/sequences/Sequence;)Ljava/util/stream/Stream; - public static final fun toList (Ljava/util/stream/DoubleStream;)Ljava/util/List; - public static final fun toList (Ljava/util/stream/IntStream;)Ljava/util/List; - public static final fun toList (Ljava/util/stream/LongStream;)Ljava/util/List; - public static final fun toList (Ljava/util/stream/Stream;)Ljava/util/List; -} - -public final class kotlin/text/RegexExtensionsJRE8Kt { - public static final fun get (Lkotlin/text/MatchGroupCollection;Ljava/lang/String;)Lkotlin/text/MatchGroup; -} - diff --git a/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/RuntimePublicAPITest.kt b/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/RuntimePublicAPITest.kt index d672aee9010..b18e847d248 100644 --- a/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/RuntimePublicAPITest.kt +++ b/libraries/tools/binary-compatibility-validator/src/test/kotlin/org.jetbrains.kotlin.tools.tests/RuntimePublicAPITest.kt @@ -33,14 +33,6 @@ class RuntimePublicAPITest { snapshotAPIAndCompare("../../stdlib/jdk8/build/libs", "kotlin-stdlib-jdk8") } - @Test fun kotlinStdlibJre7() { - snapshotAPIAndCompare("../../stdlib/jre7/build/libs", "kotlin-stdlib-jre7") - } - - @Test fun kotlinStdlibJre8() { - snapshotAPIAndCompare("../../stdlib/jre8/build/libs", "kotlin-stdlib-jre8") - } - @Test fun kotlinReflect() { snapshotAPIAndCompare("../../reflect/api/build/libs", "kotlin-reflect-api(?!-[-a-z]+)", nonPublicPackages = listOf("kotlin.reflect.jvm.internal")) } diff --git a/settings.gradle b/settings.gradle index df00ff30684..c6559055cc3 100644 --- a/settings.gradle +++ b/settings.gradle @@ -229,8 +229,6 @@ if (isJpsBuild) { include ":kotlin-stdlib-common", ":kotlin-stdlib", ":kotlin-stdlib-js", - ":kotlin-stdlib-jre7", - ":kotlin-stdlib-jre8", ":kotlin-stdlib-jdk7", ":kotlin-stdlib-jdk8", ":kotlin-stdlib:samples", @@ -245,8 +243,6 @@ if (isJpsBuild) { project(':kotlin-stdlib-common').projectDir = "$rootDir/libraries/stdlib/common" as File project(':kotlin-stdlib').projectDir = "$rootDir/libraries/stdlib/jvm" as File project(':kotlin-stdlib-js').projectDir = "$rootDir/libraries/stdlib/js" as File - project(':kotlin-stdlib-jre7').projectDir = "$rootDir/libraries/stdlib/jre7" as File - project(':kotlin-stdlib-jre8').projectDir = "$rootDir/libraries/stdlib/jre8" as File project(':kotlin-stdlib-jdk7').projectDir = "$rootDir/libraries/stdlib/jdk7" as File project(':kotlin-stdlib-jdk8').projectDir = "$rootDir/libraries/stdlib/jdk8" as File project(':kotlin-stdlib:samples').projectDir = "$rootDir/libraries/stdlib/samples" as File