Skip to content

Commit

Permalink
misc: upgrade to Kotlin 2.0.0 (#1105)
Browse files Browse the repository at this point in the history
  • Loading branch information
lauzadis authored Jul 25, 2024
1 parent 8351ac1 commit c9830c0
Show file tree
Hide file tree
Showing 48 changed files with 392 additions and 235 deletions.
50 changes: 24 additions & 26 deletions .brazil.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
{
"dependencies": {
"com.squareup.okhttp3:okhttp-coroutines-jvm:5.*": "OkHttp3CoroutinesJvm-5.x",
"org.jetbrains.kotlin:kotlin-stdlib-common:2.0.*": "KotlinStdlibCommon-2.x",
"org.jetbrains.kotlin:kotlin-stdlib:2.0.*": "KotlinStdlib-2.x",
"org.jetbrains.kotlinx:atomicfu:0.*.*": "Atomicfu-0.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.*": "KotlinxCoroutinesCoreJvm-1.8.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.*": "KotlinxCoroutinesCore-1.8.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.8.*": "KotlinxCoroutinesJdk8-1.8.x",

"com.squareup.okhttp3:okhttp-coroutines:5.*": "OkHttp3Coroutines-5.x",
"com.squareup.okhttp3:okhttp-jvm:5.*": "OkHttp3Jvm-5.x",
"com.squareup.okhttp3:okhttp:5.*": "OkHttp3-5.x",
"com.squareup.okio:okio-jvm:3.*": "OkioJvm-3.x",
"com.squareup.okio:okio:3.*": "Okio-3.x",
"io.opentelemetry:opentelemetry-api:1.*": "Maven-io-opentelemetry_opentelemetry-api-1.x",
"org.jetbrains.kotlin:kotlin-stdlib-common:1.9.*": "KotlinStdlibCommon-1.9.x",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.*": "KotlinStdlibJdk8-1.9.x",
"org.jetbrains.kotlin:kotlin-stdlib:1.9.*": "KotlinStdlib-1.9.x",
"org.jetbrains.kotlinx:atomicfu-jvm:0.23.1": "AtomicfuJvm-0.23.1",
"org.jetbrains.kotlinx:atomicfu:0.23.1": "Atomicfu-0.23.1",
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.*": "KotlinxCoroutinesCoreJvm-1.7.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.*": "KotlinxCoroutinesCore-1.7.x",
"org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.7.*": "KotlinxCoroutinesJdk8-1.7.x",
"org.slf4j:slf4j-api:2.*": "Maven-org-slf4j_slf4j-api-2.x",
"software.amazon.awssdk.crt:aws-crt:0.*": "Aws-crt-java-1.0.x",
"aws.sdk.kotlin.crt:aws-crt-kotlin:0.8.*": "AwsCrtKotlin-0.8.x"
Expand All @@ -39,27 +36,28 @@
"aws.smithy.kotlin:version-catalog"
],
"resolvesConflictDependencies": {
"com.squareup.okhttp3:okhttp-coroutines-jvm:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x",
"KotlinxCoroutinesCoreJvm-1.7.x"
],
"com.squareup.okhttp3:okhttp-coroutines:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x",
"KotlinxCoroutinesCoreJvm-1.7.x"
],
"com.squareup.okhttp3:okhttp-jvm:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x"
"KotlinStdlib-2.x",
"KotlinxCoroutinesCoreJvm-1.8.x",
"KotlinStdlibJdk7-2.x",
"KotlinStdlibJdk8-2.x"
],
"com.squareup.okhttp3:okhttp:5.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlib-1.9.x"
"KotlinStdlib-2.x"
],
"com.squareup.okio:okio-jvm:3.*": [
"KotlinStdlibCommon-1.9.x",
"KotlinStdlibJdk8-1.9.x"
"KotlinStdlib-2.x"
],
"org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.*": [
"KotlinxCoroutinesCoreJvm-1.8.x",
"KotlinStdlib-2.x"
],
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.8.*": [
"KotlinxCoroutinesCoreJvm-1.8.x",
"KotlinStdlib-2.x"
],
"org.jetbrains.kotlin:kotlin-stdlib:2.*": [
"KotlinStdlib-2.x"
],
"org.jetbrains.kotlinx:kotlinx-coroutines-core-jvm:1.7.*": [
"KotlinStdlibCommon-1.9.x",
Expand Down
6 changes: 6 additions & 0 deletions .changes/a44842e7-3418-48ce-b2a9-99718c72c43b.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"id": "a44842e7-3418-48ce-b2a9-99718c72c43b",
"type": "misc",
"description": "⚠️ **IMPORTANT**: Upgrade to Kotlin 2.0.0",
"requiresMinorVersionBump": true
}
3 changes: 2 additions & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ jobs:
- name: Test
shell: bash
run: |
echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
# FIXME K2. Re-enable warnings as errors after this warning is removed: https://youtrack.jetbrains.com/issue/KT-68532
# echo "kotlinWarningsAsErrors=true" >> $GITHUB_WORKSPACE/local.properties
./gradlew apiCheck
./gradlew test jvmTest
- name: Save Test Reports
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private fun getDefaultRuntimeVersion(): String {
// publishing info
const val RUNTIME_GROUP: String = "aws.smithy.kotlin"
val RUNTIME_VERSION: String = System.getProperty("smithy.kotlin.codegen.clientRuntimeVersion", getDefaultRuntimeVersion())
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "1.9.21")
val KOTLIN_COMPILER_VERSION: String = System.getProperty("smithy.kotlin.codegen.kotlinCompilerVersion", "2.0.0")

enum class SourceSet {
CommonMain,
Expand Down
10 changes: 4 additions & 6 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[versions]
kotlin-version = "1.9.23"
kotlin-version = "2.0.0"
dokka-version = "1.9.10"

aws-kotlin-repo-tools-version = "0.4.9"

# libs
coroutines-version = "1.7.3"
atomicfu-version = "0.23.1"
coroutines-version = "1.8.1"
atomicfu-version = "0.24.0"
okhttp-version = "5.0.0-alpha.14"
okio-version = "3.9.0"
otel-version = "1.32.0"
Expand All @@ -21,16 +21,14 @@ smithy-gradle-version = "0.9.0"
# testing
junit-version = "5.10.1"
kotest-version = "5.8.0"
kotlin-compile-testing-version = "1.5.0"
kotlin-compile-testing-version = "1.6.0"
kotlinx-benchmark-version = "0.4.9"
kotlinx-serialization-version = "1.6.0"
docker-java-version = "3.3.6"
ktor-version = "2.3.12"
kaml-version = "0.55.0"
jsoup-version = "1.16.2"



[libraries]
aws-kotlin-repo-tools-build-support = { module="aws.sdk.kotlin.gradle:build-support", version.ref = "aws-kotlin-repo-tools-version" }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ public expect class TelemetryContextElement(context: Context) : CoroutineContext
public companion object Key : CoroutineContext.Key<TelemetryContextElement>

public val context: Context
override val key: CoroutineContext.Key<*>
override fun <E : CoroutineContext.Element> get(key: CoroutineContext.Key<E>): E?
override fun <R> fold(initial: R, operation: (R, CoroutineContext.Element) -> R): R
override fun plus(context: CoroutineContext): CoroutineContext
override fun minusKey(key: CoroutineContext.Key<*>): CoroutineContext
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ val startTestServers = task<LocalTestServers>("startTestServers") {

main = "aws.smithy.kotlin.runtime.http.test.util.TestServersKt"
val kotlinCompilation = kotlin.targets.getByName("jvm").compilations["test"]
classpath = (kotlinCompilation as org.jetbrains.kotlin.gradle.plugin.KotlinCompilationToRunnableFiles<*>).runtimeDependencyFiles
classpath = kotlinCompilation.runtimeDependencyFiles!!
sslConfigPath = File.createTempFile("ssl-", ".cfg").absolutePath
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

package aws.smithy.kotlin.runtime.http.test.util

import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeout
import kotlinx.coroutines.*
import kotlin.coroutines.CoroutineContext
import kotlin.time.Duration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public interface MutableMultiMap<K, V> : MutableMap<K, MutableList<V>> {
* @param value The value to disassociate
* @return True if the given value was previously associated with the given key; otherwise, false.
*/
@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
public fun remove(key: K, value: V): Boolean

Expand Down Expand Up @@ -170,7 +170,7 @@ internal class SimpleMutableMultiMap<K, V>(

override fun hashCode(): Int = delegate.hashCode()

@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
override fun remove(key: K, value: V): Boolean = this[key]?.remove(value) ?: false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal class MutableMultiMapView<KSrc, KDest, VSrc, VDest>(
}
override fun remove(key: KDest): MutableList<VDest>? = src.remove(kDest2Src(key))?.let(vListSrc2Dest)

@Suppress("INAPPLICABLE_JVM_NAME")
@Suppress("INAPPLICABLE_JVM_NAME") // https://youtrack.jetbrains.com/issue/KT-68532
@JvmName("removeElement")
override fun remove(key: KDest, value: VDest): Boolean = src.remove(kDest2Src(key), vDest2Src(value))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@

package aws.smithy.kotlin.runtime.compression

import aws.smithy.kotlin.runtime.content.ByteStream

/**
* The gzip compression algorithm.
* Used to compress http requests.
*
* See: https://en.wikipedia.org/wiki/Gzip
*/
public expect class Gzip() : CompressionAlgorithm
public expect class Gzip() : CompressionAlgorithm {
override val id: String
override val contentEncoding: String
override fun compress(stream: ByteStream): ByteStream
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ public abstract class Crc32Base : HashFunction {
* directly to avoid doing the integer conversion yourself.
*/
@InternalApi
public expect class Crc32() : Crc32Base
public expect class Crc32() : Crc32Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun digestValue(): UInt
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the CRC32 checksum of the given [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public abstract class Md5Base : HashFunction {
* Implementation of RFC1321 MD5 digest
*/
@InternalApi
public expect class Md5() : Md5Base
public expect class Md5() : Md5Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the MD5 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ public abstract class Sha1Base : HashFunction {
* Implementation of SHA-1 (Secure Hash Algorithm 1) hash function. See: https://csrc.nist.gov/projects/hash-functions
*/
@InternalApi
public expect class Sha1() : Sha1Base
public expect class Sha1() : Sha1Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the SHA-1 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@ public abstract class Sha256Base : HashFunction {
*/
@InternalApi
public expect class Sha256() : Sha256Base
public expect class Sha256() : Sha256Base {
override fun update(input: ByteArray, offset: Int, length: Int)
override fun digest(): ByteArray
override fun reset()
override val blockSizeBytes: Int
override val digestSizeBytes: Int
}

/**
* Compute the SHA-256 hash of the current [ByteArray]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,24 @@ package aws.smithy.kotlin.runtime.io
import aws.smithy.kotlin.runtime.io.internal.toOkio
import aws.smithy.kotlin.runtime.io.internal.toSdk

internal expect class BufferedSinkAdapter(sink: okio.BufferedSink) : SdkBufferedSink
internal expect class BufferedSinkAdapter(sink: okio.BufferedSink) : SdkBufferedSink {
override fun writeShortLe(x: Short)
override fun writeUtf8(string: String, start: Int, endExclusive: Int)
override val buffer: SdkBuffer
override fun writeShort(x: Short)
override fun writeLongLe(x: Long)
override fun emit()
override fun flush()
override fun close()
override fun write(source: SdkSource, byteCount: Long)
override fun write(source: SdkBuffer, byteCount: Long)
override fun writeAll(source: SdkSource): Long
override fun writeIntLe(x: Int)
override fun writeInt(x: Int)
override fun writeByte(x: Byte)
override fun writeLong(x: Long)
override fun write(source: ByteArray, offset: Int, limit: Int)
}

// base class that fills in most of the common implementation, platforms just need to implement the platform specific
// part of the interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,29 @@ package aws.smithy.kotlin.runtime.io
import aws.smithy.kotlin.runtime.io.internal.toOkio
import aws.smithy.kotlin.runtime.io.internal.toSdk

internal expect class BufferedSourceAdapter(source: okio.BufferedSource) : SdkBufferedSource
internal expect class BufferedSourceAdapter(source: okio.BufferedSource) : SdkBufferedSource {
override val buffer: SdkBuffer
override fun read(sink: SdkBuffer, limit: Long): Long
override fun readByte(): Byte
override fun read(sink: ByteArray, offset: Int, limit: Int): Int
override fun readByteArray(): ByteArray
override fun readInt(): Int
override fun readIntLe(): Int
override fun readLongLe(): Long
override fun readLong(): Long
override fun readShort(): Short
override fun readShortLe(): Short
override fun readUtf8(): String
override fun readUtf8(byteCount: Long): String
override fun readByteArray(byteCount: Long): ByteArray
override fun request(byteCount: Long): Boolean
override fun exhausted(): Boolean
override fun readAll(sink: SdkSink): Long
override fun require(byteCount: Long)
override fun skip(byteCount: Long)
override fun peek(): SdkBufferedSource
override fun close()
}

// base class that fills in most of the common implementation, platforms just need to implement the platform specific
// part of the interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,11 @@ package aws.smithy.kotlin.runtime.io
/**
* Wraps the SdkByteReadChannel so that it compresses into gzip format with each read.
*/
public expect class GzipByteReadChannel(channel: SdkByteReadChannel) : SdkByteReadChannel
public expect class GzipByteReadChannel(channel: SdkByteReadChannel) : SdkByteReadChannel {
override suspend fun read(sink: SdkBuffer, limit: Long): Long
override fun cancel(cause: Throwable?): Boolean
override val availableForRead: Int
override val isClosedForWrite: Boolean
override val isClosedForRead: Boolean
override val closedCause: Throwable?
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ package aws.smithy.kotlin.runtime.io
/**
* Wraps the SdkSource so that it compresses into gzip format with each read.
*/
public expect class GzipSdkSource(source: SdkSource) : SdkSource
public expect class GzipSdkSource(source: SdkSource) : SdkSource {
override fun read(sink: SdkBuffer, limit: Long): Long
override fun close()
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,39 @@ public expect class SdkBuffer :
internal constructor(buffer: okio.Buffer)

override val buffer: SdkBuffer

override fun close()
override fun require(byteCount: Long)
override fun skip(byteCount: Long)
override fun exhausted(): Boolean
override fun readShortLe(): Short
override fun readUtf8(): String
override fun readShort(): Short
override fun readIntLe(): Int
override fun readLong(): Long
override fun readInt(): Int
override fun peek(): SdkBufferedSource
override fun readLongLe(): Long
override fun readByte(): Byte
override fun readByteArray(): ByteArray
override fun request(byteCount: Long): Boolean
override fun readAll(sink: SdkSink): Long
override fun emit()
override fun flush()
override fun read(sink: SdkBuffer, limit: Long): Long
override fun read(sink: ByteArray, offset: Int, limit: Int): Int
override fun readByteArray(byteCount: Long): ByteArray
override fun readUtf8(byteCount: Long): String
override fun write(source: SdkBuffer, byteCount: Long)
override fun write(source: SdkSource, byteCount: Long)
override fun write(source: ByteArray, offset: Int, limit: Int)
override fun writeAll(source: SdkSource): Long
override fun writeByte(x: Byte)
override fun writeInt(x: Int)
override fun writeIntLe(x: Int)
override fun writeLong(x: Long)
override fun writeLongLe(x: Long)
override fun writeShort(x: Short)
override fun writeShortLe(x: Short)
override fun writeUtf8(string: String, start: Int, endExclusive: Int)
}
Loading

0 comments on commit c9830c0

Please sign in to comment.