Skip to content

Commit 3b3b3c6

Browse files
authored
Update Kotlin to 2.2.0 (#455)
* Update Kotlin to 2.2.0 * Drop `ExperimentalEncodingApi` and `ExperimentalStdlibApi` as Base64 and Hex APIs are stable from Kotlin 2.2.0 * Fix wasmWasi preopens configuration
1 parent aa54743 commit 3b3b3c6

File tree

21 files changed

+24
-73
lines changed

21 files changed

+24
-73
lines changed

build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-android-compat.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ pluginManager.withPlugin("org.gradle.java-base") {
99
apply(plugin = "ru.vyarus.animalsniffer")
1010

1111
configure<AnimalSnifferExtension> {
12-
sourceSets = listOf((project.extensions.getByName("sourceSets") as SourceSetContainer).getByName("main"))
12+
defaultTargets = setOf("jvmMain")
1313
}
1414
val signature: Configuration by configurations
1515
dependencies {

build-logic/src/main/kotlin/kotlinx/io/conventions/kotlinx-io-multiplatform.gradle.kts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import kotlinx.io.build.configureJava9ModuleInfoCompilation
77
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
88
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
9+
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
910
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
1011
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
1112
import kotlin.jvm.optionals.getOrNull
@@ -30,17 +31,11 @@ kotlin {
3031
}
3132

3233
jvm {
33-
withJava()
3434
testRuns["test"].executionTask.configure {
3535
useJUnitPlatform()
3636
}
37-
// can be replaced with just `compilerOptions { }` in Kotlin 2.0
38-
compilations.configureEach {
39-
compileTaskProvider.configure {
40-
compilerOptions {
41-
freeCompilerArgs.add("-Xjvm-default=all")
42-
}
43-
}
37+
compilerOptions {
38+
jvmDefault = JvmDefaultMode.NO_COMPATIBILITY
4439
}
4540

4641
val mrjToolchain = versionCatalog.findVersion("multi.release.toolchain").getOrNull()?.requiredVersion

bytestring/apple/test/ByteStringAppleTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import platform.Foundation.NSData
1212
import platform.Foundation.create
1313
import platform.posix.memset
1414
import kotlin.io.encoding.Base64
15-
import kotlin.io.encoding.ExperimentalEncodingApi
1615
import kotlin.test.*
1716

1817
@OptIn(UnsafeNumber::class)
@@ -27,12 +26,12 @@ class ByteStringAppleTest {
2726
assertContentEquals(byteArrayOf(0, 1, 2, 3, 4, 5), copy.bytes!!.readBytes(copy.length.convert()))
2827
}
2928

30-
@OptIn(BetaInteropApi::class, ExperimentalEncodingApi::class)
29+
@OptIn(BetaInteropApi::class)
3130
@Test
3231
fun fromNSData() {
3332
assertTrue(NSData().toByteString().isEmpty())
3433
val src = NSData.create(
35-
base64EncodedString = Base64.Default.encode(byteArrayOf(0, 1, 2, 3, 4, 5)),
34+
base64EncodedString = Base64.encode(byteArrayOf(0, 1, 2, 3, 4, 5)),
3635
options = 0u
3736
)!!
3837
val copy = src.toByteString()

bytestring/apple/test/samples/samplesApple.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import platform.Foundation.*
1212
import kotlin.test.*
1313

1414
class ByteStringSamplesApple {
15-
@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalStdlibApi::class)
15+
@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
1616
@Test
1717
fun nsDataConversion() {
1818
val originalByteString: ByteString = "Compress me, please!".encodeToByteString()

bytestring/common/src/Base64.kt

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
package kotlinx.io.bytestring
77

88
import kotlin.io.encoding.Base64
9-
import kotlin.io.encoding.Base64.Default.encode
10-
import kotlin.io.encoding.Base64.Default.encodeToByteArray
11-
import kotlin.io.encoding.ExperimentalEncodingApi
129

1310
/**
1411
* Encodes bytes from the specified [source] byte string or its subrange.
@@ -30,7 +27,6 @@ import kotlin.io.encoding.ExperimentalEncodingApi
3027
*
3128
* @return a [ByteArray] with the resulting symbols.
3229
*/
33-
@ExperimentalEncodingApi
3430
public fun Base64.encodeToByteArray(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray {
3531
return encodeToByteArray(source.getBackingArrayReference(), startIndex, endIndex)
3632
}
@@ -55,7 +51,6 @@ public fun Base64.encodeToByteArray(source: ByteString, startIndex: Int = 0, end
5551
*
5652
* @return the number of symbols written into [destination] array.
5753
*/
58-
@ExperimentalEncodingApi
5954
public fun Base64.encodeIntoByteArray(
6055
source: ByteString,
6156
destination: ByteArray,
@@ -84,7 +79,6 @@ public fun Base64.encodeIntoByteArray(
8479
*
8580
* @return a string with the resulting symbols.
8681
*/
87-
@ExperimentalEncodingApi
8882
public fun Base64.encode(
8983
source: ByteString,
9084
startIndex: Int = 0,
@@ -110,7 +104,6 @@ public fun Base64.encode(
110104
*
111105
* @return the destination appendable.
112106
*/
113-
@ExperimentalEncodingApi
114107
public fun <A : Appendable> Base64.encodeToAppendable(
115108
source: ByteString,
116109
destination: A,
@@ -139,7 +132,6 @@ public fun <A : Appendable> Base64.encodeToAppendable(
139132
*
140133
* @return a [ByteArray] with the resulting bytes.
141134
*/
142-
@ExperimentalEncodingApi
143135
public fun Base64.decode(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteArray {
144136
return decode(source.getBackingArrayReference(), startIndex, endIndex)
145137
}
@@ -162,7 +154,6 @@ public fun Base64.decode(source: ByteString, startIndex: Int = 0, endIndex: Int
162154
*
163155
* @return a [ByteArray] with the resulting bytes.
164156
*/
165-
@ExperimentalEncodingApi
166157
public fun Base64.decodeToByteString(source: CharSequence, startIndex: Int = 0, endIndex: Int = source.length): ByteString {
167158
return ByteString.wrap(decode(source, startIndex, endIndex))
168159
}
@@ -189,7 +180,6 @@ public fun Base64.decodeToByteString(source: CharSequence, startIndex: Int = 0,
189180
*
190181
* @return the number of bytes written into [destination] array.
191182
*/
192-
@ExperimentalEncodingApi
193183
public fun Base64.decodeIntoByteArray(
194184
source: ByteString,
195185
destination: ByteArray,
@@ -218,7 +208,6 @@ public fun Base64.decodeIntoByteArray(
218208
*
219209
* @return a [ByteString] with the resulting bytes.
220210
*/
221-
@ExperimentalEncodingApi
222211
public fun Base64.decodeToByteString(source: ByteArray, startIndex: Int = 0, endIndex: Int = source.size): ByteString {
223212
return ByteString.wrap(decode(source, startIndex, endIndex))
224213
}
@@ -241,7 +230,6 @@ public fun Base64.decodeToByteString(source: ByteArray, startIndex: Int = 0, end
241230
*
242231
* @return a [ByteString] with the resulting bytes.
243232
*/
244-
@ExperimentalEncodingApi
245233
public fun Base64.decodeToByteString(source: ByteString, startIndex: Int = 0, endIndex: Int = source.size): ByteString {
246234
return ByteString.wrap(decode(source.getBackingArrayReference(), startIndex, endIndex))
247235
}

bytestring/common/src/Hex.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ package kotlinx.io.bytestring
1414
*
1515
* @throws IllegalArgumentException if the result length is more than [String] maximum capacity.
1616
*/
17-
@ExperimentalStdlibApi
1817
public fun ByteString.toHexString(format: HexFormat = HexFormat.Default): String {
1918
return getBackingArrayReference().toHexString(0, getBackingArrayReference().size, format)
2019
}
@@ -32,7 +31,6 @@ public fun ByteString.toHexString(format: HexFormat = HexFormat.Default): String
3231
* @throws IllegalArgumentException when `startIndex > endIndex`.
3332
* @throws IllegalArgumentException if the result length is more than [String] maximum capacity.
3433
*/
35-
@ExperimentalStdlibApi
3634
public fun ByteString.toHexString(
3735
startIndex: Int = 0,
3836
endIndex: Int = size,
@@ -52,7 +50,6 @@ public fun ByteString.toHexString(
5250
*
5351
* @throws IllegalArgumentException if this string does not comply with the specified [format].
5452
*/
55-
@ExperimentalStdlibApi
5653
public fun String.hexToByteString(format: HexFormat = HexFormat.Default): ByteString {
5754
return ByteString.wrap(hexToByteArray(format))
5855
}

bytestring/common/test/ByteStringBase64Test.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
44
*/
55

6-
@file:OptIn(ExperimentalEncodingApi::class)
7-
86
package kotlinx.io.bytestring
97

108
import kotlin.io.encoding.Base64
11-
import kotlin.io.encoding.ExperimentalEncodingApi
129
import kotlin.test.*
1310

1411
class ByteStringBase64Test {

bytestring/common/test/ByteStringHexTest.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
44
*/
55

6-
@file:OptIn(ExperimentalStdlibApi::class)
7-
86
package kotlinx.io.bytestring
97

108
import kotlin.test.Test

core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tasks.named("wasmWasiNodeTest") {
6161
val templateFile = layout.projectDirectory.file("wasmWasi/test/test-driver.mjs.template").asFile
6262

6363
val driverFile = layout.buildDirectory.file(
64-
"compileSync/wasmWasi/test/testDevelopmentExecutable/kotlin/kotlinx-io-kotlinx-io-core-wasm-wasi-test.mjs"
64+
"compileSync/wasmWasi/test/testDevelopmentExecutable/kotlin/kotlinx-io-kotlinx-io-core-test.mjs"
6565
)
6666

6767
fun File.mkdirsAndEscape(): String {

core/common/test/Utf8Test.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,6 @@ class Utf8Test {
432432
buffer.assertUtf8StringDecoded("${REPLACEMENT_CHARACTER}aaa", "f0616161")
433433
}
434434

435-
@OptIn(ExperimentalStdlibApi::class)
436435
@Test
437436
fun encodeUtf16SurrogatePair() {
438437
val buffer = Buffer()

0 commit comments

Comments
 (0)