diff --git a/.idea/runConfigurations/All_Tests.xml b/.idea/runConfigurations/All_Tests.xml
index bd453b48194..c10cb9f786f 100644
--- a/.idea/runConfigurations/All_Tests.xml
+++ b/.idea/runConfigurations/All_Tests.xml
@@ -1,29 +1,24 @@
-
+
-
-
-
-
+
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 0401596d045..41dda4f5e6d 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -92,8 +92,8 @@ apply(from = "gradle/compatibility.gradle")
plugins {
id("org.jetbrains.dokka") version "1.7.20" apply false
- id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.13.2"
- id("kotlinx-atomicfu") version "0.22.0" apply false
+ id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.12.1"
+ id("kotlinx-atomicfu") version "0.19.0" apply false
id("com.osacky.doctor") version "0.8.1"
}
diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts
index 11845b73978..339f9caf446 100644
--- a/buildSrc/build.gradle.kts
+++ b/buildSrc/build.gradle.kts
@@ -24,8 +24,8 @@ sourceSets.main {
val ktor_version = "2.3.2"
dependencies {
- implementation(kotlin("gradle-plugin", "1.9.10"))
- implementation(kotlin("serialization", "1.9.10"))
+ implementation(kotlin("gradle-plugin", "1.8.22"))
+ implementation(kotlin("serialization", "1.8.22"))
val ktlint_version = libs.versions.ktlint.version.get()
implementation("org.jmailen.gradle:kotlinter-gradle:$ktlint_version")
diff --git a/buildSrc/src/main/kotlin/Publication.kt b/buildSrc/src/main/kotlin/Publication.kt
index 90b81eec028..0ff4e7b2851 100644
--- a/buildSrc/src/main/kotlin/Publication.kt
+++ b/buildSrc/src/main/kotlin/Publication.kt
@@ -184,17 +184,5 @@ fun Project.configurePublication() {
gpgAgentLock.unlock()
}
}
-
- val publishLinuxX64PublicationToMavenRepository = tasks.findByName("publishLinuxX64PublicationToMavenRepository")
- val signLinuxArm64Publication = tasks.findByName("signLinuxArm64Publication")
- if (publishLinuxX64PublicationToMavenRepository != null && signLinuxArm64Publication != null) {
- publishLinuxX64PublicationToMavenRepository.dependsOn(signLinuxArm64Publication)
- }
-
- val publishLinuxArm64PublicationToMavenRepository = tasks.findByName("publishLinuxArm64PublicationToMavenRepository")
- val signLinuxX64Publication = tasks.findByName("signLinuxX64Publication")
- if (publishLinuxArm64PublicationToMavenRepository != null && signLinuxX64Publication != null) {
- publishLinuxArm64PublicationToMavenRepository.dependsOn(signLinuxX64Publication)
- }
}
}
diff --git a/gradle.properties b/gradle.properties
index 62271e21273..df9d60707b6 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -32,7 +32,7 @@ kotlin.native.binary.memoryModel=experimental
kotlin_version=1.8.22
coroutines_version=1.7.1
-atomicfu_version=0.22.0
+atomicfu_version=0.19.0
slf4j_version=1.7.36
junit_version=4.13.2
logback_version=1.2.11
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 5380cf1c89b..dcd4524b018 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -1,8 +1,8 @@
[versions]
kotlin-version = "1.8.22"
kotlinx-html-version = "0.9.1"
-coroutines-version = "1.7.3"
-atomicfu-version = "0.22.0"
+coroutines-version = "1.7.1"
+atomicfu-version = "0.19.0"
serialization-version = "1.5.1"
validator-version = "0.8.0"
ktlint-version = "3.15.0"
diff --git a/ktor-client/ktor-client-core/api/ktor-client-core.api b/ktor-client/ktor-client-core/api/ktor-client-core.api
index 83573b3c89e..eb7300814ad 100644
--- a/ktor-client/ktor-client-core/api/ktor-client-core.api
+++ b/ktor-client/ktor-client-core/api/ktor-client-core.api
@@ -212,7 +212,6 @@ public final class io/ktor/client/engine/ProxyType : java/lang/Enum {
public static final field HTTP Lio/ktor/client/engine/ProxyType;
public static final field SOCKS Lio/ktor/client/engine/ProxyType;
public static final field UNKNOWN Lio/ktor/client/engine/ProxyType;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/client/engine/ProxyType;
public static fun values ()[Lio/ktor/client/engine/ProxyType;
}
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/Curl.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/Curl.kt
index da096cb9719..68322f5395a 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/Curl.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/Curl.kt
@@ -19,7 +19,6 @@ import libcurl.*
@EagerInitialization
private val curlGlobalInitReturnCode = curlInitBridge()
-@OptIn(ExperimentalForeignApi::class)
internal fun curlInitBridge(): Int = curl_global_init(CURL_GLOBAL_ALL.convert()).convert()
@OptIn(ExperimentalStdlibApi::class)
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/CurlProcessor.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/CurlProcessor.kt
index adf41f6e1aa..c71a24d6f99 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/CurlProcessor.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/CurlProcessor.kt
@@ -58,7 +58,6 @@ internal class CurlProcessor(coroutineContext: CoroutineContext) {
}
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun drainRequestQueue(api: CurlMultiApiHandler) {
while (true) {
val container = if (api.hasHandlers()) {
@@ -93,7 +92,6 @@ internal class CurlProcessor(coroutineContext: CoroutineContext) {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun cancelRequest(easyHandle: EasyHandle, cause: Throwable) {
curlScope.launch {
curlApi!!.cancelRequest(easyHandle, cause)
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlAdapters.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlAdapters.kt
index ef270ec4693..d99c89b2503 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlAdapters.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlAdapters.kt
@@ -14,13 +14,11 @@ import libcurl.*
// These should have been CPointer and CPointer, I suppose,
// but somehow cinterop tool makes them just opaque pointers.
-@OptIn(ExperimentalForeignApi::class)
+
internal typealias EasyHandle = COpaquePointer
-@OptIn(ExperimentalForeignApi::class)
internal typealias MultiHandle = COpaquePointer
-@OptIn(ExperimentalForeignApi::class)
internal fun CURLMcode.verify() {
if (this != CURLM_OK) {
@Suppress("DEPRECATION")
@@ -28,7 +26,6 @@ internal fun CURLMcode.verify() {
}
}
-@OptIn(ExperimentalForeignApi::class)
internal fun CURLcode.verify() {
if (this != CURLE_OK) {
@Suppress("DEPRECATION")
@@ -36,37 +33,31 @@ internal fun CURLcode.verify() {
}
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.option(option: CURLoption, optionValue: Int) {
curl_easy_setopt(this, option, optionValue).verify()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.option(option: CURLoption, optionValue: Long) {
curl_easy_setopt(this, option, optionValue).verify()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.option(option: CURLoption, optionValue: CPointer<*>) {
curl_easy_setopt(this, option, optionValue).verify()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.option(option: CURLoption, optionValue: CValuesRef<*>) {
curl_easy_setopt(this, option, optionValue).verify()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.option(option: CURLoption, optionValue: String) {
curl_easy_setopt(this, option, optionValue).verify()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun EasyHandle.getInfo(info: CURLINFO, optionValue: CPointer<*>) {
curl_easy_getinfo(this, info, optionValue).verify()
}
-@OptIn(InternalAPI::class, ExperimentalForeignApi::class)
+@OptIn(InternalAPI::class)
internal fun HttpRequestData.headersToCurl(): CPointer {
var result: CPointer? = null
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlCallbacks.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlCallbacks.kt
index 68816039369..23a3690f0ba 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlCallbacks.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlCallbacks.kt
@@ -13,7 +13,6 @@ import libcurl.*
import platform.posix.*
import kotlin.coroutines.*
-@OptIn(ExperimentalForeignApi::class)
internal fun onHeadersReceived(
buffer: CPointer,
size: size_t,
@@ -27,7 +26,6 @@ internal fun onHeadersReceived(
}
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
internal fun onBodyChunkReceived(
buffer: CPointer,
size: size_t,
@@ -74,7 +72,6 @@ internal fun onBodyChunkReceived(
}
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
internal fun onBodyChunkRequested(
buffer: CPointer,
size: size_t,
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlMultiApiHandler.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlMultiApiHandler.kt
index 95a34bbf084..444d9068583 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlMultiApiHandler.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlMultiApiHandler.kt
@@ -12,12 +12,12 @@ import kotlinx.cinterop.*
import kotlinx.coroutines.*
import libcurl.*
-private class RequestHolder @OptIn(ExperimentalForeignApi::class) constructor(
+private class RequestHolder constructor(
val responseCompletable: CompletableDeferred,
val requestWrapper: StableRef,
val responseWrapper: StableRef,
) {
- @OptIn(ExperimentalForeignApi::class)
+
fun dispose() {
requestWrapper.dispose()
responseWrapper.dispose()
@@ -25,23 +25,19 @@ private class RequestHolder @OptIn(ExperimentalForeignApi::class) constructor(
}
internal class CurlMultiApiHandler : Closeable {
- @OptIn(ExperimentalForeignApi::class)
+
private val activeHandles = mutableMapOf()
- @OptIn(ExperimentalForeignApi::class)
private val cancelledHandles = mutableSetOf>()
- @OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
private val multiHandle: MultiHandle = curl_multi_init()
?: throw CurlRuntimeException("Could not initialize curl multi handle")
private val easyHandlesToUnpauseLock = SynchronizedObject()
- @OptIn(ExperimentalForeignApi::class)
private val easyHandlesToUnpause = mutableListOf()
- @OptIn(ExperimentalForeignApi::class)
override fun close() {
for ((handle, holder) in activeHandles) {
curl_multi_remove_handle(multiHandle, handle).verify()
@@ -53,7 +49,6 @@ internal class CurlMultiApiHandler : Closeable {
curl_multi_cleanup(multiHandle).verify()
}
- @OptIn(ExperimentalForeignApi::class)
fun scheduleRequest(request: CurlRequestData, deferred: CompletableDeferred): EasyHandle {
val easyHandle = curl_easy_init()
?: throw
@@ -129,13 +124,11 @@ internal class CurlMultiApiHandler : Closeable {
return easyHandle
}
- @OptIn(ExperimentalForeignApi::class)
internal fun cancelRequest(easyHandle: EasyHandle, cause: Throwable) {
cancelledHandles += Pair(easyHandle, cause)
curl_multi_remove_handle(multiHandle, easyHandle).verify()
}
- @OptIn(ExperimentalForeignApi::class)
internal fun perform() {
if (activeHandles.isEmpty()) return
@@ -160,10 +153,8 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
internal fun hasHandlers(): Boolean = activeHandles.isNotEmpty()
- @OptIn(ExperimentalForeignApi::class)
private fun setupMethod(
easyHandle: EasyHandle,
method: String,
@@ -187,7 +178,6 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun setupUploadContent(easyHandle: EasyHandle, request: CurlRequestData): COpaquePointer {
val requestPointer = CurlRequestBodyData(
body = request.content,
@@ -208,7 +198,6 @@ internal class CurlMultiApiHandler : Closeable {
return requestPointer
}
- @OptIn(ExperimentalForeignApi::class)
private fun handleCompleted() {
for (cancellation in cancelledHandles) {
val cancelled = processCancelledEasyHandle(cancellation.first, cancellation.second)
@@ -246,7 +235,6 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun processCancelledEasyHandle(easyHandle: EasyHandle, cause: Throwable): CurlFail = memScoped {
try {
val responseDataRef = alloc()
@@ -264,7 +252,6 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun processCompletedEasyHandle(
message: CURLMSG?,
easyHandle: EasyHandle,
@@ -293,7 +280,6 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun collectFailedResponse(
message: CURLMSG?,
request: CurlRequestData,
@@ -334,7 +320,6 @@ internal class CurlMultiApiHandler : Closeable {
)
}
- @OptIn(ExperimentalForeignApi::class)
private fun collectSuccessResponse(easyHandle: EasyHandle): CurlSuccess? = memScoped {
val responseDataRef = alloc()
val httpProtocolVersion = alloc()
@@ -363,7 +348,6 @@ internal class CurlMultiApiHandler : Closeable {
}
}
- @OptIn(ExperimentalForeignApi::class)
fun wakeup() {
curl_multi_wakeup(multiHandle)
}
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlRaw.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlRaw.kt
index 376c48477a5..acb76f26c95 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlRaw.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/CurlRaw.kt
@@ -18,7 +18,6 @@ import kotlinx.coroutines.*
import libcurl.*
import kotlin.coroutines.*
-@OptIn(ExperimentalForeignApi::class)
internal suspend fun HttpRequestData.toCurlRequest(config: CurlClientEngineConfig): CurlRequestData = CurlRequestData(
url = url.toString(),
method = method.value,
@@ -34,7 +33,7 @@ internal suspend fun HttpRequestData.toCurlRequest(config: CurlClientEngineConfi
caPath = config.caPath
)
-internal class CurlRequestData @OptIn(ExperimentalForeignApi::class) constructor(
+internal class CurlRequestData constructor(
val url: String,
val method: String,
val headers: CPointer,
diff --git a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/NativeUtils.kt b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/NativeUtils.kt
index d6d7d0d678b..3f406d034f0 100644
--- a/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/NativeUtils.kt
+++ b/ktor-client/ktor-client-curl/desktop/src/io/ktor/client/engine/curl/internal/NativeUtils.kt
@@ -7,15 +7,12 @@ package io.ktor.client.engine.curl.internal
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal fun ByteArray.copyToBuffer(buffer: CPointer, size: ULong, position: Int = 0) {
usePinned { pinned ->
memcpy(buffer, pinned.addressOf(position), size.convert())
}
}
-@OptIn(ExperimentalForeignApi::class)
internal inline fun T.asStablePointer(): COpaquePointer = StableRef.create(this).asCPointer()
-@OptIn(ExperimentalForeignApi::class)
internal inline fun COpaquePointer.fromCPointer(): T = asStableRef().get()
diff --git a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/certificates/LegacyCertificatePinner.kt b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/certificates/LegacyCertificatePinner.kt
index 0426700f927..4b260086300 100644
--- a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/certificates/LegacyCertificatePinner.kt
+++ b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/certificates/LegacyCertificatePinner.kt
@@ -113,7 +113,6 @@ public data class LegacyCertificatePinner internal constructor(
private val validateTrust: Boolean
) : ChallengeHandler {
- @OptIn(ExperimentalForeignApi::class)
override fun invoke(
session: NSURLSession,
task: NSURLSessionTask,
@@ -182,7 +181,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Confirms that at least one of the certificates is pinned
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun hasOnePinnedCertificate(
certificates: List
): Boolean = certificates.any { certificate ->
@@ -218,7 +217,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Build an error string to display
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun buildErrorMessage(
certificates: List,
hostname: String
@@ -261,7 +260,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Evaluates trust for the specified certificate and policies.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun SecTrustRef.trustIsValid(): Boolean {
var isValid = false
@@ -292,7 +291,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Gets the public key from the SecCertificate
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun SecCertificateRef.getPublicKeyBytes(): ByteArray? {
val publicKeyRef = SecCertificateCopyKey(this) ?: return null
@@ -326,7 +325,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Checks that we support the key type and size
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun checkValidKeyType(publicKeyType: NSString, publicKeySize: NSNumber): Boolean {
val keyTypeRSA = CFBridgingRelease(kSecAttrKeyTypeRSA) as NSString
val keyTypeECSECPrimeRandom = CFBridgingRelease(kSecAttrKeyTypeECSECPrimeRandom) as NSString
@@ -345,7 +344,7 @@ public data class LegacyCertificatePinner internal constructor(
* Get the [IntArray] of Asn1 headers needed to prepend to the public key to create the
* encoding [ASN1Header](https://docs.oracle.com/middleware/11119/opss/SCRPJ/oracle/security/crypto/asn1/ASN1Header.html)
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun getAsn1HeaderBytes(publicKeyType: NSString, publicKeySize: NSNumber): IntArray {
val keyTypeRSA = CFBridgingRelease(kSecAttrKeyTypeRSA) as NSString
val keyTypeECSECPrimeRandom = CFBridgingRelease(kSecAttrKeyTypeECSECPrimeRandom) as NSString
@@ -363,7 +362,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Converts a [ByteArray] into sha256 base 64 encoded string
*/
- @OptIn(ExperimentalUnsignedTypes::class, ExperimentalForeignApi::class)
+ @OptIn(ExperimentalUnsignedTypes::class)
private fun ByteArray.toSha256String(): String {
val digest = UByteArray(CC_SHA256_DIGEST_LENGTH)
@@ -379,7 +378,7 @@ public data class LegacyCertificatePinner internal constructor(
/**
* Converts a [ByteArray] into sha1 base 64 encoded string
*/
- @OptIn(ExperimentalUnsignedTypes::class, ExperimentalForeignApi::class)
+ @OptIn(ExperimentalUnsignedTypes::class)
private fun ByteArray.toSha1String(): String {
val digest = UByteArray(CC_SHA1_DIGEST_LENGTH)
diff --git a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyTaskHandler.kt b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyTaskHandler.kt
index 9ab4d9deb0d..3c5c900233e 100644
--- a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyTaskHandler.kt
+++ b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyTaskHandler.kt
@@ -67,7 +67,7 @@ internal class DarwinLegacyTaskHandler(
bodyChunks.close()
}
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
fun NSHTTPURLResponse.toResponseData(): HttpResponseData = HttpResponseData(
HttpStatusCode.fromValue(statusCode.convert()),
requestTime,
diff --git a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyUtils.kt b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyUtils.kt
index fe7fe2e1c13..b5e4e73d8a3 100644
--- a/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyUtils.kt
+++ b/ktor-client/ktor-client-darwin-legacy/darwin/src/io/ktor/client/engine/darwin/internal/legacy/DarwinLegacyUtils.kt
@@ -24,7 +24,7 @@ internal suspend fun OutgoingContent.toNSData(): NSData? = when (this) {
else -> throw UnsupportedContentTypeException(this)
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun ByteArray.toNSData(): NSData = NSMutableData().apply {
if (isEmpty()) return@apply
this@toNSData.usePinned {
@@ -32,7 +32,7 @@ internal fun ByteArray.toNSData(): NSData = NSMutableData().apply {
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun NSData.toByteArray(): ByteArray {
val result = ByteArray(length.toInt())
if (result.isEmpty()) return result
@@ -48,7 +48,7 @@ internal fun NSData.toByteArray(): ByteArray {
* Executes the given block function on this resource and then releases it correctly whether an
* exception is thrown or not.
*/
-@OptIn(ExperimentalForeignApi::class)
+
internal inline fun CPointer.use(block: (CPointer) -> R): R {
try {
return block(this)
diff --git a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/DarwinUtils.kt b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/DarwinUtils.kt
index b0ef88cba68..774fe0cc5a8 100644
--- a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/DarwinUtils.kt
+++ b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/DarwinUtils.kt
@@ -19,8 +19,6 @@ import platform.posix.*
DelicateCoroutinesApi::class,
UnsafeNumber::class,
InternalAPI::class,
- ExperimentalForeignApi::class,
- BetaInteropApi::class
)
internal suspend fun OutgoingContent.toDataOrStream(): Any? {
if (this is OutgoingContent.ByteArrayContent) return bytes().toNSData()
@@ -79,7 +77,7 @@ internal suspend fun OutgoingContent.toDataOrStream(): Any? {
return inputStream
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun ByteArray.toNSData(): NSData = NSMutableData().apply {
if (isEmpty()) return@apply
this@toNSData.usePinned {
@@ -87,7 +85,7 @@ internal fun ByteArray.toNSData(): NSData = NSMutableData().apply {
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun NSData.toByteArray(): ByteArray {
val result = ByteArray(length.toInt())
if (result.isEmpty()) return result
@@ -103,7 +101,7 @@ internal fun NSData.toByteArray(): ByteArray {
* Executes the given block function on this resource and then releases it correctly whether an
* exception is thrown or not.
*/
-@OptIn(ExperimentalForeignApi::class)
+
internal inline fun CPointer.use(block: (CPointer) -> R): R {
try {
return block(this)
diff --git a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/certificates/CertificatePinner.kt b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/certificates/CertificatePinner.kt
index d7d676b12ae..b246a9cd34c 100644
--- a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/certificates/CertificatePinner.kt
+++ b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/certificates/CertificatePinner.kt
@@ -112,7 +112,6 @@ public data class CertificatePinner internal constructor(
private val validateTrust: Boolean
) : ChallengeHandler {
- @OptIn(ExperimentalForeignApi::class)
override fun invoke(
session: NSURLSession,
task: NSURLSessionTask,
@@ -181,7 +180,7 @@ public data class CertificatePinner internal constructor(
/**
* Confirms that at least one of the certificates is pinned
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun hasOnePinnedCertificate(
certificates: List
): Boolean = certificates.any { certificate ->
@@ -217,7 +216,7 @@ public data class CertificatePinner internal constructor(
/**
* Build an error string to display
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun buildErrorMessage(
certificates: List,
hostname: String
@@ -260,7 +259,7 @@ public data class CertificatePinner internal constructor(
/**
* Evaluates trust for the specified certificate and policies.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun SecTrustRef.trustIsValid(): Boolean {
var isValid = false
@@ -291,7 +290,7 @@ public data class CertificatePinner internal constructor(
/**
* Gets the public key from the SecCertificate
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun SecCertificateRef.getPublicKeyBytes(): ByteArray? {
val publicKeyRef = SecCertificateCopyKey(this) ?: return null
@@ -325,7 +324,7 @@ public data class CertificatePinner internal constructor(
/**
* Checks that we support the key type and size
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun checkValidKeyType(publicKeyType: NSString, publicKeySize: NSNumber): Boolean {
val keyTypeRSA = CFBridgingRelease(kSecAttrKeyTypeRSA) as NSString
val keyTypeECSECPrimeRandom = CFBridgingRelease(kSecAttrKeyTypeECSECPrimeRandom) as NSString
@@ -344,7 +343,7 @@ public data class CertificatePinner internal constructor(
* Get the [IntArray] of Asn1 headers needed to prepend to the public key to create the
* encoding [ASN1Header](https://docs.oracle.com/middleware/11119/opss/SCRPJ/oracle/security/crypto/asn1/ASN1Header.html)
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun getAsn1HeaderBytes(publicKeyType: NSString, publicKeySize: NSNumber): IntArray {
val keyTypeRSA = CFBridgingRelease(kSecAttrKeyTypeRSA) as NSString
val keyTypeECSECPrimeRandom = CFBridgingRelease(kSecAttrKeyTypeECSECPrimeRandom) as NSString
@@ -362,7 +361,7 @@ public data class CertificatePinner internal constructor(
/**
* Converts a [ByteArray] into sha256 base 64 encoded string
*/
- @OptIn(ExperimentalUnsignedTypes::class, ExperimentalForeignApi::class)
+ @OptIn(ExperimentalUnsignedTypes::class)
private fun ByteArray.toSha256String(): String {
val digest = UByteArray(CC_SHA256_DIGEST_LENGTH)
@@ -378,7 +377,7 @@ public data class CertificatePinner internal constructor(
/**
* Converts a [ByteArray] into sha1 base 64 encoded string
*/
- @OptIn(ExperimentalUnsignedTypes::class, ExperimentalForeignApi::class)
+ @OptIn(ExperimentalUnsignedTypes::class)
private fun ByteArray.toSha1String(): String {
val digest = UByteArray(CC_SHA1_DIGEST_LENGTH)
diff --git a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinTaskHandler.kt b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinTaskHandler.kt
index 88c174ade6a..9ce7c06e650 100644
--- a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinTaskHandler.kt
+++ b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinTaskHandler.kt
@@ -68,7 +68,7 @@ internal class DarwinTaskHandler(
bodyChunks.close()
}
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
fun NSHTTPURLResponse.toResponseData(): HttpResponseData = HttpResponseData(
HttpStatusCode.fromValue(statusCode.convert()),
requestTime,
diff --git a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinWebsocketSession.kt b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinWebsocketSession.kt
index 1ed11c83dd3..8a4caf56449 100644
--- a/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinWebsocketSession.kt
+++ b/ktor-client/ktor-client-darwin/darwin/src/io/ktor/client/engine/darwin/internal/DarwinWebsocketSession.kt
@@ -17,7 +17,7 @@ import platform.Foundation.*
import platform.darwin.*
import kotlin.coroutines.*
-@OptIn(UnsafeNumber::class, ExperimentalCoroutinesApi::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class, ExperimentalCoroutinesApi::class)
internal class DarwinWebsocketSession(
callContext: CoroutineContext,
private val task: NSURLSessionWebSocketTask,
@@ -35,7 +35,6 @@ internal class DarwinWebsocketSession(
get() = true
set(_) {}
- @OptIn(ExperimentalForeignApi::class)
override var maxFrameSize: Long
get() = task.maximumMessageSize.convert()
set(value) {
diff --git a/ktor-client/ktor-client-darwin/darwin/test/DarwinEngineTest.kt b/ktor-client/ktor-client-darwin/darwin/test/DarwinEngineTest.kt
index 0be9654d981..15716edd2d9 100644
--- a/ktor-client/ktor-client-darwin/darwin/test/DarwinEngineTest.kt
+++ b/ktor-client/ktor-client-darwin/darwin/test/DarwinEngineTest.kt
@@ -201,7 +201,7 @@ class DarwinEngineTest {
assertEquals("my header value", response.bodyAsText())
}
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
@Test
fun testConfigureWebsocketRequest(): Unit = runBlocking {
var customChallengeCalled = false
diff --git a/ktor-client/ktor-client-plugins/ktor-client-logging/api/ktor-client-logging.api b/ktor-client/ktor-client-plugins/ktor-client-logging/api/ktor-client-logging.api
index 66c48459ea7..91de0e26db9 100644
--- a/ktor-client/ktor-client-plugins/ktor-client-logging/api/ktor-client-logging.api
+++ b/ktor-client/ktor-client-plugins/ktor-client-logging/api/ktor-client-logging.api
@@ -5,7 +5,6 @@ public final class io/ktor/client/plugins/logging/LogLevel : java/lang/Enum {
public static final field INFO Lio/ktor/client/plugins/logging/LogLevel;
public static final field NONE Lio/ktor/client/plugins/logging/LogLevel;
public final fun getBody ()Z
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getHeaders ()Z
public final fun getInfo ()Z
public static fun valueOf (Ljava/lang/String;)Lio/ktor/client/plugins/logging/LogLevel;
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCallback.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCallback.kt
index d298727fe8f..35d8e925907 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCallback.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCallback.kt
@@ -9,7 +9,6 @@ import platform.windows.*
import platform.windows.HINTERNET
import platform.winhttp.*
-@OptIn(ExperimentalForeignApi::class)
internal enum class WinHttpCallbackStatus(val value: UInt) {
SecureFailure(WINHTTP_CALLBACK_STATUS_SECURE_FAILURE.convert()),
HeadersAvailable(WINHTTP_CALLBACK_STATUS_HEADERS_AVAILABLE.convert()),
@@ -21,7 +20,6 @@ internal enum class WinHttpCallbackStatus(val value: UInt) {
CloseComplete(WINHTTP_CALLBACK_STATUS_CLOSE_COMPLETE.convert())
}
-@OptIn(ExperimentalForeignApi::class)
internal fun winHttpCallback(
@Suppress("UNUSED_PARAMETER")
hInternet: HINTERNET?,
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpConnect.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpConnect.kt
index bbb95b5e9ff..d7157c8b8a5 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpConnect.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpConnect.kt
@@ -11,7 +11,6 @@ import kotlinx.cinterop.*
import platform.windows.*
import platform.winhttp.*
-@OptIn(ExperimentalForeignApi::class)
internal typealias WinHttpStatusHandler = (statusInfo: LPVOID?, statusInfoLength: DWORD) -> Unit
internal class WinHttpConnect @OptIn(ExperimentalForeignApi::class) constructor(private val hConnect: COpaquePointer) :
@@ -19,7 +18,6 @@ internal class WinHttpConnect @OptIn(ExperimentalForeignApi::class) constructor(
private val closed = atomic(false)
- @OptIn(ExperimentalForeignApi::class)
val handlers = mutableMapOf()
val isClosed: Boolean
@@ -31,7 +29,7 @@ internal class WinHttpConnect @OptIn(ExperimentalForeignApi::class) constructor(
* @param url is request URL.
* @param chunkedMode is request body chunking mode.
*/
- @OptIn(ExperimentalForeignApi::class)
+
fun openRequest(
method: HttpMethod,
url: Url,
@@ -56,12 +54,10 @@ internal class WinHttpConnect @OptIn(ExperimentalForeignApi::class) constructor(
)
}
- @OptIn(ExperimentalForeignApi::class)
fun on(status: WinHttpCallbackStatus, handler: WinHttpStatusHandler) {
handlers[status.value] = handler
}
- @OptIn(ExperimentalForeignApi::class)
override fun close() {
if (!closed.compareAndSet(expect = false, update = true)) return
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCoroutine.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCoroutine.kt
index 55836d54ce2..5f7e328e8e3 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCoroutine.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpCoroutine.kt
@@ -10,7 +10,6 @@ import kotlinx.coroutines.*
import platform.winhttp.*
import kotlin.coroutines.*
-@OptIn(ExperimentalForeignApi::class)
internal suspend inline fun Closeable.closeableCoroutine(
state: WinHttpConnect,
errorMessage: String,
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpExceptions.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpExceptions.kt
index 2ac6cd4dba4..7e0113b4656 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpExceptions.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpExceptions.kt
@@ -9,15 +9,12 @@ import kotlinx.cinterop.*
import platform.windows.*
import platform.winhttp.*
-@OptIn(ExperimentalForeignApi::class)
private val winHttpModuleHandle by lazy {
GetModuleHandleW("winhttp.dll")
}
-@OptIn(ExperimentalForeignApi::class)
private val languageId = makeLanguageId(LANG_NEUTRAL.convert(), SUBLANG_DEFAULT.convert())
-@OptIn(ExperimentalForeignApi::class)
private val ERROR_INSUFFICIENT_BUFFER: UInt = platform.windows.ERROR_INSUFFICIENT_BUFFER.convert()
/**
@@ -46,7 +43,7 @@ internal fun getWinHttpException(message: String, errorCode: UInt): Exception {
/**
* Creates an error message from WinAPI error code.
*/
-@OptIn(ExperimentalForeignApi::class)
+
internal fun getErrorMessage(errorCode: UInt): String {
return formatMessage(errorCode, winHttpModuleHandle)
?: formatMessage(errorCode)
@@ -59,7 +56,7 @@ internal fun getErrorMessage(errorCode: UInt): String {
* @param errorCode is error code.
* @param moduleHandle is DLL handle to look for message.
*/
-@OptIn(ExperimentalForeignApi::class)
+
private fun formatMessage(errorCode: UInt, moduleHandle: HMODULE? = null): String? = memScoped {
val formatSourceFlag = if (moduleHandle != null) {
FORMAT_MESSAGE_FROM_HMODULE
@@ -118,7 +115,6 @@ private fun formatMessage(errorCode: UInt, moduleHandle: HMODULE? = null): Strin
}
}
-@OptIn(ExperimentalForeignApi::class)
private fun CPointer.toKStringFromUtf16(size: Int): String {
val nativeBytes = this
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequest.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequest.kt
index fa6174ff337..666fb5d3e66 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequest.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequest.kt
@@ -18,20 +18,17 @@ import platform.windows.SECURITY_FLAG_IGNORE_UNKNOWN_CA
import platform.winhttp.*
import kotlin.coroutines.*
-@OptIn(ExperimentalForeignApi::class)
-internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
+internal class WinHttpRequest constructor(
hSession: COpaquePointer,
data: HttpRequestData,
config: WinHttpClientEngineConfig
) : Closeable {
private val connect: WinHttpConnect
- @OptIn(ExperimentalForeignApi::class)
private val hRequest: COpaquePointer
private val closed = atomic(false)
private val requestClosed = atomic(false)
- @OptIn(ExperimentalForeignApi::class)
private val connectReference: StableRef
init {
@@ -206,7 +203,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
*
* @param callContext is call context.
*/
- @OptIn(ExperimentalForeignApi::class)
+
fun createWebSocket(callContext: CoroutineContext): WinHttpWebSocket {
val statePtr = connectReference.asCPointer().rawValue.toLong()
val hWebsocket = WinHttpWebSocketCompleteUpgrade(hRequest, statePtr.convert())
@@ -220,7 +217,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Disables built-in features which are handled by Ktor client.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun configureFeatures() = memScoped {
val options = alloc {
value = (WINHTTP_DISABLE_COOKIES or WINHTTP_DISABLE_REDIRECTS).convert()
@@ -240,7 +237,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Receive status callbacks about all operations.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun configureStatusCallback(enable: Boolean) = memScoped {
val notifications = WINHTTP_CALLBACK_FLAG_ALL_COMPLETIONS.convert()
val callback = if (enable) {
@@ -263,7 +260,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
*
* @param protocolVersion is required protocol version.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun enableHttpProtocols(protocolVersion: HttpProtocolVersion) = memScoped {
if (protocolVersion != HttpProtocolVersion.HTTP_2_0) return@memScoped
val flags = alloc {
@@ -275,7 +272,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Disables TLS verification for testing purposes.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun disableTlsVerification() = memScoped {
val flags = alloc {
value = (
@@ -301,7 +298,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Gets a string length in bytes.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun getLength(dwSize: UIntVar) = (dwSize.value / sizeOf().convert()).convert()
/**
@@ -309,7 +306,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
*
* @param headerId is header identifier.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun getHeader(headerId: Int): String = memScoped {
val dwSize = alloc()
@@ -333,7 +330,7 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Gets a HTTP protocol version from server response.
*/
- @OptIn(ExperimentalForeignApi::class)
+
private fun isHttp2Response() = memScoped {
val flags = alloc()
val dwSize = alloc {
@@ -347,7 +344,6 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
false
}
- @OptIn(ExperimentalForeignApi::class)
private fun closeRequest() {
if (!requestClosed.compareAndSet(expect = false, update = true)) return
@@ -355,7 +351,6 @@ internal class WinHttpRequest @OptIn(ExperimentalForeignApi::class) constructor(
WinHttpCloseHandle(hRequest)
}
- @OptIn(ExperimentalForeignApi::class)
override fun close() {
if (!closed.compareAndSet(expect = false, update = true)) return
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequestProducer.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequestProducer.kt
index 4c7da91ee4d..2c9ef6e440e 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequestProducer.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpRequestProducer.kt
@@ -55,7 +55,6 @@ internal class WinHttpRequestProducer(
}
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun writeChunkedBody(requestBody: ByteReadChannel, readBuffer: ByteArray) {
while (true) {
val readBytes = requestBody.readAvailable(readBuffer).takeIf { it > 0 } ?: break
@@ -66,7 +65,6 @@ internal class WinHttpRequestProducer(
}
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun writeBodyChunk(readBuffer: ByteArray, length: Int) {
// Write chunk length
val chunkStart = "${length.toString(16)}\r\n".toByteArray()
@@ -83,7 +81,6 @@ internal class WinHttpRequestProducer(
}
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun writeRegularBody(requestBody: ByteReadChannel, readBuffer: ByteArray) {
while (true) {
val readBytes = requestBody.readAvailable(readBuffer).takeIf { it > 0 } ?: break
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpResponseConsumer.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpResponseConsumer.kt
index 0719b694b68..087d6d7568f 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpResponseConsumer.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpResponseConsumer.kt
@@ -10,7 +10,7 @@ import kotlinx.cinterop.*
import kotlinx.coroutines.*
import kotlin.coroutines.*
-@OptIn(DelicateCoroutinesApi::class, ExperimentalForeignApi::class)
+@OptIn(DelicateCoroutinesApi::class)
internal fun WinHttpRequest.readBody(callContext: CoroutineContext): ByteReadChannel {
return GlobalScope.writer(callContext) {
val readBuffer = ByteArrayPool.borrow()
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpSession.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpSession.kt
index 93b65af79ee..e7e31fb2f3b 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpSession.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpSession.kt
@@ -13,10 +13,8 @@ import kotlinx.atomicfu.*
import kotlinx.cinterop.*
import platform.winhttp.*
-@OptIn(ExperimentalForeignApi::class)
internal class WinHttpSession(private val config: WinHttpClientEngineConfig) : Closeable {
- @OptIn(ExperimentalForeignApi::class)
private var hSession: COpaquePointer
private val closed = atomic(false)
diff --git a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpWebSocket.kt b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpWebSocket.kt
index 4a35a42846f..15faecac322 100644
--- a/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpWebSocket.kt
+++ b/ktor-client/ktor-client-winhttp/windows/src/io/ktor/client/engine/winhttp/internal/WinHttpWebSocket.kt
@@ -23,8 +23,7 @@ private object WinHttpWebSocketBuffer {
val Close = WINHTTP_WEB_SOCKET_CLOSE_BUFFER_TYPE
}
-@OptIn(ExperimentalForeignApi::class)
-internal class WinHttpWebSocket @OptIn(ExperimentalForeignApi::class) constructor(
+internal class WinHttpWebSocket constructor(
private val hWebSocket: COpaquePointer,
private val connect: WinHttpConnect,
callContext: CoroutineContext
diff --git a/ktor-http/api/ktor-http.api b/ktor-http/api/ktor-http.api
index 58ea3afe709..7d5d2ee2bd6 100644
--- a/ktor-http/api/ktor-http.api
+++ b/ktor-http/api/ktor-http.api
@@ -40,7 +40,6 @@ public final class io/ktor/http/CacheControl$NoStore : io/ktor/http/CacheControl
public final class io/ktor/http/CacheControl$Visibility : java/lang/Enum {
public static final field Private Lio/ktor/http/CacheControl$Visibility;
public static final field Public Lio/ktor/http/CacheControl$Visibility;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/CacheControl$Visibility;
public static fun values ()[Lio/ktor/http/CacheControl$Visibility;
}
@@ -295,7 +294,6 @@ public final class io/ktor/http/CookieEncoding : java/lang/Enum {
public static final field DQUOTES Lio/ktor/http/CookieEncoding;
public static final field RAW Lio/ktor/http/CookieEncoding;
public static final field URI_ENCODING Lio/ktor/http/CookieEncoding;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/CookieEncoding;
public static fun values ()[Lio/ktor/http/CookieEncoding;
}
@@ -839,7 +837,6 @@ public final class io/ktor/http/QueryKt {
public final class io/ktor/http/RangeUnits : java/lang/Enum {
public static final field Bytes Lio/ktor/http/RangeUnits;
public static final field None Lio/ktor/http/RangeUnits;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getUnitToken ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/RangeUnits;
public static fun values ()[Lio/ktor/http/RangeUnits;
@@ -1068,7 +1065,6 @@ public final class io/ktor/http/auth/HeaderValueEncoding : java/lang/Enum {
public static final field QUOTED_ALWAYS Lio/ktor/http/auth/HeaderValueEncoding;
public static final field QUOTED_WHEN_REQUIRED Lio/ktor/http/auth/HeaderValueEncoding;
public static final field URI_ENCODE Lio/ktor/http/auth/HeaderValueEncoding;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/auth/HeaderValueEncoding;
public static fun values ()[Lio/ktor/http/auth/HeaderValueEncoding;
}
@@ -1346,7 +1342,6 @@ public final class io/ktor/http/content/VersionCheckResult : java/lang/Enum {
public static final field NOT_MODIFIED Lio/ktor/http/content/VersionCheckResult;
public static final field OK Lio/ktor/http/content/VersionCheckResult;
public static final field PRECONDITION_FAILED Lio/ktor/http/content/VersionCheckResult;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getStatusCode ()Lio/ktor/http/HttpStatusCode;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/http/content/VersionCheckResult;
public static fun values ()[Lio/ktor/http/content/VersionCheckResult;
diff --git a/ktor-io/api/ktor-io.api b/ktor-io/api/ktor-io.api
index 3f5f23068cc..8034e21a864 100644
--- a/ktor-io/api/ktor-io.api
+++ b/ktor-io/api/ktor-io.api
@@ -864,7 +864,6 @@ public final class io/ktor/utils/io/core/ByteOrder : java/lang/Enum {
public static final field BIG_ENDIAN Lio/ktor/utils/io/core/ByteOrder;
public static final field Companion Lio/ktor/utils/io/core/ByteOrder$Companion;
public static final field LITTLE_ENDIAN Lio/ktor/utils/io/core/ByteOrder;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getNioOrder ()Ljava/nio/ByteOrder;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/utils/io/core/ByteOrder;
public static fun values ()[Lio/ktor/utils/io/core/ByteOrder;
diff --git a/ktor-io/darwin/src/CharsetDarwin.kt b/ktor-io/darwin/src/CharsetDarwin.kt
index 1321a46881f..62686a6dadb 100644
--- a/ktor-io/darwin/src/CharsetDarwin.kt
+++ b/ktor-io/darwin/src/CharsetDarwin.kt
@@ -140,7 +140,7 @@ internal actual fun CharsetEncoder.encodeToByteArrayImpl1(
?: throw MalformedInputException("Failed to convert String to Bytes using $charset")
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun ByteArray.toNSData(): NSData = NSMutableData().apply {
if (isEmpty()) return@apply
this@toNSData.usePinned {
@@ -148,7 +148,7 @@ private fun ByteArray.toNSData(): NSData = NSMutableData().apply {
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun NSData.toByteArray(): ByteArray {
val result = ByteArray(length.toInt())
if (result.isEmpty()) return result
diff --git a/ktor-io/linux/src/CharsetLinux.kt b/ktor-io/linux/src/CharsetLinux.kt
index e2918a90fb7..9e44fa72c93 100644
--- a/ktor-io/linux/src/CharsetLinux.kt
+++ b/ktor-io/linux/src/CharsetLinux.kt
@@ -23,7 +23,6 @@ internal actual fun findCharset(name: String): Charset {
return CharsetIconv(name)
}
-@OptIn(ExperimentalForeignApi::class)
private class CharsetIconv(name: String) : Charset(name) {
init {
val v = iconv_open(name, "UTF-8")
@@ -40,17 +39,15 @@ internal fun iconvCharsetName(name: String) = when (name) {
else -> name
}
-@OptIn(ExperimentalForeignApi::class)
private val negativePointer = (-1L).toCPointer()
-@OptIn(ExperimentalForeignApi::class)
internal fun checkErrors(iconvOpenResults: COpaquePointer?, charset: String) {
if (iconvOpenResults == null || iconvOpenResults === negativePointer) {
throw IllegalArgumentException("Failed to open iconv for charset $charset with error code ${posix_errno()}")
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun CharsetEncoder.encodeImpl(input: CharSequence, fromIndex: Int, toIndex: Int, dst: Buffer): Int {
val length = toIndex - fromIndex
if (length == 0) return 0
@@ -93,7 +90,7 @@ internal actual fun CharsetEncoder.encodeImpl(input: CharSequence, fromIndex: In
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun CharsetDecoder.decode(input: Input, dst: Appendable, max: Int): Int {
val charset = iconvCharsetName(charset.name)
val cd = iconv_open(platformUtf16, charset)
@@ -164,7 +161,6 @@ public actual fun CharsetDecoder.decode(input: Input, dst: Appendable, max: Int)
}
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun CharsetDecoder.decodeBuffer(
input: Buffer,
out: Appendable,
@@ -247,7 +243,6 @@ internal actual fun CharsetEncoder.encodeToByteArrayImpl1(
}
}
-@OptIn(ExperimentalForeignApi::class)
public actual fun CharsetDecoder.decodeExactBytes(input: Input, inputLength: Int): String {
if (inputLength == 0) return ""
@@ -319,7 +314,6 @@ public actual fun CharsetDecoder.decodeExactBytes(input: Input, inputLength: Int
}
}
-@OptIn(ExperimentalForeignApi::class)
public actual fun CharsetEncoder.encodeUTF8(input: ByteReadPacket, dst: Output) {
val cd = iconv_open(charset.name, "UTF-8")
checkErrors(cd, "UTF-8")
diff --git a/ktor-io/mingwX64/src/CharsetMingw.kt b/ktor-io/mingwX64/src/CharsetMingw.kt
index 6a2c07e6917..804e846f4c9 100644
--- a/ktor-io/mingwX64/src/CharsetMingw.kt
+++ b/ktor-io/mingwX64/src/CharsetMingw.kt
@@ -15,7 +15,6 @@ public actual object Charsets {
internal val UTF_16: Charset = CharsetIconv(platformUtf16)
}
-@OptIn(ExperimentalForeignApi::class)
private class CharsetIconv(name: String) : Charset(name) {
init {
val v = iconv_open(name, "UTF-8")
@@ -40,10 +39,8 @@ internal fun iconvCharsetName(name: String) = when (name) {
else -> name
}
-@OptIn(ExperimentalForeignApi::class)
private val negativePointer = (-1L).toCPointer()
-@OptIn(ExperimentalForeignApi::class)
internal fun checkErrors(iconvOpenResults: COpaquePointer?, charset: String) {
if (iconvOpenResults == null || iconvOpenResults === negativePointer) {
throw IllegalArgumentException("Failed to open iconv for charset $charset with error code ${posix_errno()}")
@@ -51,7 +48,7 @@ internal fun checkErrors(iconvOpenResults: COpaquePointer?, charset: String) {
}
@Suppress("DEPRECATION")
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun CharsetEncoder.encodeImpl(input: CharSequence, fromIndex: Int, toIndex: Int, dst: Buffer): Int {
val length = toIndex - fromIndex
if (length == 0) return 0
@@ -95,7 +92,7 @@ internal actual fun CharsetEncoder.encodeImpl(input: CharSequence, fromIndex: In
}
@Suppress("DEPRECATION")
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun CharsetDecoder.decode(input: Input, dst: Appendable, max: Int): Int {
val charset = iconvCharsetName(charset.name)
val cd = iconv_open(platformUtf16, charset)
@@ -166,7 +163,6 @@ public actual fun CharsetDecoder.decode(input: Input, dst: Appendable, max: Int)
}
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun CharsetDecoder.decodeBuffer(
input: Buffer,
out: Appendable,
@@ -249,7 +245,6 @@ internal actual fun CharsetEncoder.encodeToByteArrayImpl1(
}
}
-@OptIn(ExperimentalForeignApi::class)
public actual fun CharsetDecoder.decodeExactBytes(input: Input, inputLength: Int): String {
if (inputLength == 0) return ""
@@ -321,7 +316,6 @@ public actual fun CharsetDecoder.decodeExactBytes(input: Input, inputLength: Int
}
}
-@OptIn(ExperimentalForeignApi::class)
public actual fun CharsetEncoder.encodeUTF8(input: ByteReadPacket, dst: Output) {
val cd = iconv_open(charset.name, "UTF-8")
checkErrors(cd, "UTF-8")
diff --git a/ktor-io/posix/src/io/ktor/utils/io/ByteChannelNative.kt b/ktor-io/posix/src/io/ktor/utils/io/ByteChannelNative.kt
index 68a8fc859ba..ee949c2a094 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/ByteChannelNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/ByteChannelNative.kt
@@ -112,11 +112,9 @@ internal class ByteChannelNative(
return result
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun readAvailable(dst: CPointer, offset: Int, length: Int): Int =
readAvailable(dst, offset.toLong(), length.toLong())
- @OptIn(ExperimentalForeignApi::class)
override suspend fun readAvailable(dst: CPointer, offset: Long, length: Long): Int {
require(offset >= 0L)
require(length >= 0L)
@@ -138,12 +136,10 @@ internal class ByteChannelNative(
return size
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun readFully(dst: CPointer, offset: Int, length: Int) {
readFully(dst, offset.toLong(), length.toLong())
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun readFully(dst: CPointer, offset: Long, length: Long) {
require(offset >= 0L)
require(length >= 0L)
@@ -163,7 +159,6 @@ internal class ByteChannelNative(
}
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun readFullySuspend(dst: CPointer, offset: Long, length: Long) {
var position = offset
var rem = length
@@ -182,12 +177,10 @@ internal class ByteChannelNative(
}
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun writeFully(src: CPointer, offset: Int, length: Int) {
return writeFully(src, offset.toLong(), length.toLong())
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun writeFully(src: CPointer, offset: Long, length: Long) {
if (availableForWrite > 0) {
val size = tryWriteCPointer(src, offset, length).toLong()
@@ -204,7 +197,6 @@ internal class ByteChannelNative(
return writeFullySuspend(src, offset, length)
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun writeFullySuspend(src: CPointer, offset: Long, length: Long) {
var remaining = length
var position = offset
@@ -238,11 +230,9 @@ internal class ByteChannelNative(
return size
}
- @OptIn(ExperimentalForeignApi::class)
override suspend fun writeAvailable(src: CPointer, offset: Int, length: Int): Int =
writeAvailable(src, offset.toLong(), length.toLong())
- @OptIn(ExperimentalForeignApi::class)
override suspend fun writeAvailable(src: CPointer, offset: Long, length: Long): Int {
if (availableForWrite > 0) {
val size = tryWriteCPointer(src, offset, length)
@@ -272,13 +262,11 @@ internal class ByteChannelNative(
return "ByteChannel[0x$hashCode, job: $attachedJob, cause: $closedCause]"
}
- @OptIn(ExperimentalForeignApi::class)
private suspend fun writeAvailableSuspend(src: CPointer, offset: Long, length: Long): Int {
awaitAtLeastNBytesAvailableForWrite(1)
return writeAvailable(src, offset, length)
}
- @OptIn(ExperimentalForeignApi::class)
private fun tryWriteCPointer(src: CPointer, offset: Long, length: Long): Int {
val size = minOf(length, availableForWrite.toLong(), Int.MAX_VALUE.toLong()).toInt()
val ptr: CPointer = (src + offset)!!
@@ -286,7 +274,6 @@ internal class ByteChannelNative(
return size
}
- @OptIn(ExperimentalForeignApi::class)
private fun tryReadCPointer(dst: CPointer, offset: Long, length: Long): Int {
val size = minOf(length, availableForRead.toLong(), Int.MAX_VALUE.toLong()).toInt()
val ptr: CPointer = (dst + offset)!!
diff --git a/ktor-io/posix/src/io/ktor/utils/io/ByteReadChannelNative.kt b/ktor-io/posix/src/io/ktor/utils/io/ByteReadChannelNative.kt
index 1a93a55e751..48fca02b635 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/ByteReadChannelNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/ByteReadChannelNative.kt
@@ -75,14 +75,14 @@ public actual interface ByteReadChannel {
* Reads all available bytes to [dst] buffer and returns immediately or suspends if no bytes available
* @return number of bytes were read or `-1` if the channel has been closed
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun readAvailable(dst: CPointer, offset: Int, length: Int): Int
/**
* Reads all available bytes to [dst] buffer and returns immediately or suspends if no bytes available
* @return number of bytes were read or `-1` if the channel has been closed
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun readAvailable(dst: CPointer, offset: Long, length: Long): Int
/**
@@ -101,14 +101,14 @@ public actual interface ByteReadChannel {
* Reads all [length] bytes to [dst] buffer or fails if channel has been closed.
* Suspends if not enough bytes available.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun readFully(dst: CPointer, offset: Int, length: Int)
/**
* Reads all [length] bytes to [dst] buffer or fails if channel has been closed.
* Suspends if not enough bytes available.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun readFully(dst: CPointer, offset: Long, length: Long)
/**
diff --git a/ktor-io/posix/src/io/ktor/utils/io/ByteWriteChannelNative.kt b/ktor-io/posix/src/io/ktor/utils/io/ByteWriteChannelNative.kt
index 20e4f697308..fe92df1d021 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/ByteWriteChannelNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/ByteWriteChannelNative.kt
@@ -72,13 +72,13 @@ public actual interface ByteWriteChannel {
/**
* Writes as much as possible and only suspends if buffer is full
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun writeAvailable(src: CPointer, offset: Int, length: Int): Int
/**
* Writes as much as possible and only suspends if buffer is full
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun writeAvailable(src: CPointer, offset: Long, length: Long): Int
/**
@@ -91,14 +91,14 @@ public actual interface ByteWriteChannel {
* Writes all [src] bytes and suspends until all bytes written. Causes flush if buffer filled up or when [autoFlush]
* Crashes if channel get closed while writing.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun writeFully(src: CPointer, offset: Int, length: Int)
/**
* Writes all [src] bytes and suspends until all bytes written. Causes flush if buffer filled up or when [autoFlush]
* Crashes if channel get closed while writing.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public suspend fun writeFully(src: CPointer, offset: Long, length: Long)
@Suppress("DEPRECATION")
diff --git a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryFactoryNative.kt b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryFactoryNative.kt
index 608a4301dda..64a8987f943 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryFactoryNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryFactoryNative.kt
@@ -12,7 +12,7 @@ import kotlin.contracts.*
* By default, if neither [offset] nor [length] specified, the whole array is used.
* An instance of [Memory] provided into the [block] should be never captured and used outside of lambda.
*/
-@OptIn(ExperimentalContracts::class, ExperimentalForeignApi::class)
+@OptIn(ExperimentalContracts::class)
public actual inline fun ByteArray.useMemory(offset: Int, length: Int, block: (Memory) -> R): R {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
@@ -32,7 +32,7 @@ public actual inline fun ByteArray.useMemory(offset: Int, length: Int, block
* Create an instance of [Memory] view for memory region starting at
* the specified [pointer] and having the specified [size] in bytes.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public inline fun Memory.Companion.of(pointer: CPointer<*>, size: size_t): Memory {
require(size.convert() <= Long.MAX_VALUE.convert()) {
"At most ${Long.MAX_VALUE} (kotlin.Long.MAX_VALUE) bytes range is supported."
@@ -45,7 +45,7 @@ public inline fun Memory.Companion.of(pointer: CPointer<*>, size: size_t): Memor
* Create an instance of [Memory] view for memory region starting at
* the specified [pointer] and having the specified [size] in bytes.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public inline fun Memory.Companion.of(pointer: CPointer<*>, size: Int): Memory {
return Memory(pointer.reinterpret(), size.toLong())
}
@@ -54,7 +54,7 @@ public inline fun Memory.Companion.of(pointer: CPointer<*>, size: Int): Memory {
* Create an instance of [Memory] view for memory region starting at
* the specified [pointer] and having the specified [size] in bytes.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public inline fun Memory.Companion.of(pointer: CPointer<*>, size: Long): Memory {
return Memory(pointer.reinterpret(), size)
}
@@ -67,7 +67,7 @@ public inline fun Memory.Companion.of(pointer: CPointer<*>, size: Long): Memory
* once the scope is leaved, all produced instances should be discarded and should be never used after the scope.
* On the contrary instances created using [nativeHeap] do require release via [nativeHeap.free].
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun NativePlacement.allocMemory(size: Int): Memory {
return allocMemory(size.toLong())
}
@@ -80,7 +80,7 @@ public fun NativePlacement.allocMemory(size: Int): Memory {
* once the scope is leaved, all produced instances should be discarded and should be never used after the scope.
* On the contrary instances created using [nativeHeap] do require release via [nativeHeap.free].
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun NativePlacement.allocMemory(size: Long): Memory {
return Memory(allocArray(size), size)
}
@@ -90,12 +90,11 @@ public fun NativePlacement.allocMemory(size: Long): Memory {
* This function should be only used for memory instances that are produced by [allocMemory] function
* otherwise an undefined behaviour may occur including crash or data corruption.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun NativeFreeablePlacement.free(memory: Memory) {
free(memory.pointer)
}
-@OptIn(ExperimentalForeignApi::class)
internal value class PlacementAllocator(private val placement: NativeFreeablePlacement) : Allocator {
override fun alloc(size: Int): Memory = alloc(size.toLong())
@@ -106,6 +105,5 @@ internal value class PlacementAllocator(private val placement: NativeFreeablePla
}
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal actual object DefaultAllocator : Allocator by PlacementAllocator(nativeHeap)
diff --git a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryNative.kt b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryNative.kt
index 2fbf5b81b95..0a8125abe74 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryNative.kt
@@ -7,7 +7,7 @@ import kotlinx.cinterop.*
import platform.posix.*
import kotlin.experimental.*
-public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
+public actual class Memory constructor(
public val pointer: CPointer,
public actual inline val size: Long
) {
@@ -24,19 +24,19 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Returns byte at [index] position.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public actual inline fun loadAt(index: Int): Byte = pointer[assertIndex(index, 1)]
/**
* Returns byte at [index] position.
*/
- @OptIn(ExperimentalForeignApi::class)
+
public actual inline fun loadAt(index: Long): Byte = pointer[assertIndex(index, 1)]
/**
* Write [value] at the specified [index].
*/
- @OptIn(ExperimentalForeignApi::class)
+
public actual inline fun storeAt(index: Int, value: Byte) {
pointer[assertIndex(index, 1)] = value
}
@@ -44,12 +44,11 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
/**
* Write [value] at the specified [index]
*/
- @OptIn(ExperimentalForeignApi::class)
+
public actual inline fun storeAt(index: Long, value: Byte) {
pointer[assertIndex(index, 1)] = value
}
- @OptIn(ExperimentalForeignApi::class)
public actual fun slice(offset: Long, length: Long): Memory {
assertIndex(offset, length)
if (offset == 0L && length == size) {
@@ -59,7 +58,6 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
return Memory(pointer.plus(offset)!!, length)
}
- @OptIn(ExperimentalForeignApi::class)
public actual fun slice(offset: Int, length: Int): Memory {
assertIndex(offset, length)
if (offset == 0 && length.toLong() == size) {
@@ -74,7 +72,7 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
* to the [destination] at [destinationOffset].
* Copying bytes from a memory to itself is allowed.
*/
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
public actual fun copyTo(destination: Memory, offset: Int, length: Int, destinationOffset: Int) {
require(offset >= 0) { "offset shouldn't be negative: $offset" }
require(length >= 0) { "length shouldn't be negative: $length" }
@@ -103,7 +101,7 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
* to the [destination] at [destinationOffset].
* Copying bytes from a memory to itself is allowed.
*/
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
public actual fun copyTo(destination: Memory, offset: Long, length: Long, destinationOffset: Long) {
require(offset >= 0L) { "offset shouldn't be negative: $offset" }
require(length >= 0L) { "length shouldn't be negative: $length" }
@@ -128,7 +126,7 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
}
public actual companion object {
- @OptIn(ExperimentalForeignApi::class)
+
public actual val Empty: Memory = Memory(nativeHeap.allocArray(0), 0L)
}
}
@@ -137,7 +135,7 @@ public actual class Memory @OptIn(ExperimentalForeignApi::class) constructor(
* Copies bytes from this memory range from the specified [offset] and [length]
* to the [destination] at [destinationOffset].
*/
-@OptIn(ExperimentalForeignApi::class)
+
public actual fun Memory.copyTo(
destination: ByteArray,
offset: Int,
@@ -163,7 +161,7 @@ public actual fun Memory.copyTo(
* Copies bytes from this memory range from the specified [offset] and [length]
* to the [destination] at [destinationOffset].
*/
-@OptIn(ExperimentalForeignApi::class)
+
public actual fun Memory.copyTo(
destination: ByteArray,
offset: Long,
@@ -185,7 +183,6 @@ public actual fun Memory.copyTo(
}
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Memory.assertIndex(offset: Int, valueSize: Int): Int {
assert(offset in 0..size - valueSize) {
@@ -194,7 +191,6 @@ internal inline fun Memory.assertIndex(offset: Int, valueSize: Int): Int {
return offset
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Memory.assertIndex(offset: Long, valueSize: Long): Long {
assert(offset in 0..size - valueSize) {
@@ -203,7 +199,6 @@ internal inline fun Memory.assertIndex(offset: Long, valueSize: Long): Long {
return offset
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Short.toBigEndian(): Short {
return when {
@@ -212,28 +207,24 @@ internal inline fun Short.toBigEndian(): Short {
}
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Int.toBigEndian(): Int = when {
!Platform.isLittleEndian -> this
else -> reverseByteOrder()
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Long.toBigEndian(): Long = when {
!Platform.isLittleEndian -> this
else -> reverseByteOrder()
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Float.toBigEndian(): Float = when {
!Platform.isLittleEndian -> this
else -> reverseByteOrder()
}
-@OptIn(ExperimentalNativeApi::class)
@PublishedApi
internal inline fun Double.toBigEndian(): Double = when {
!Platform.isLittleEndian -> this
@@ -243,7 +234,7 @@ internal inline fun Double.toBigEndian(): Double = when {
/**
* Fill memory range starting at the specified [offset] with [value] repeated [count] times.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.fill(offset: Long, count: Long, value: Byte) {
requirePositiveIndex(offset, "offset")
requirePositiveIndex(count, "count")
@@ -258,7 +249,7 @@ public actual fun Memory.fill(offset: Long, count: Long, value: Byte) {
/**
* Fill memory range starting at the specified [offset] with [value] repeated [count] times.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.fill(offset: Int, count: Int, value: Byte) {
requirePositiveIndex(offset, "offset")
requirePositiveIndex(count, "count")
@@ -275,7 +266,7 @@ public actual fun Memory.fill(offset: Int, count: Int, value: Byte) {
* Copy content bytes to the memory addressed by the [destination] pointer with
* the specified [destinationOffset] in bytes.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun Memory.copyTo(
destination: CPointer,
offset: Int,
@@ -289,7 +280,7 @@ public fun Memory.copyTo(
* Copy content bytes to the memory addressed by the [destination] pointer with
* the specified [destinationOffset] in bytes.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public fun Memory.copyTo(
destination: CPointer,
offset: Long,
@@ -308,7 +299,7 @@ public fun Memory.copyTo(
* Copy [length] bytes to the [destination] at the specified [destinationOffset]
* from the memory addressed by this pointer with [offset] in bytes.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun CPointer.copyTo(destination: Memory, offset: Int, length: Int, destinationOffset: Int) {
copyTo(destination, offset.toLong(), length.toLong(), destinationOffset.toLong())
}
@@ -317,7 +308,7 @@ public fun CPointer.copyTo(destination: Memory, offset: Int, length: In
* Copy [length] bytes to the [destination] at the specified [destinationOffset]
* from the memory addressed by this pointer with [offset] in bytes.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public fun CPointer.copyTo(destination: Memory, offset: Long, length: Long, destinationOffset: Long) {
requirePositiveIndex(offset, "offset")
requirePositiveIndex(length, "length")
diff --git a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryPrimitivesNative.kt b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryPrimitivesNative.kt
index 80b719fe513..ee858ccaea0 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryPrimitivesNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/bits/MemoryPrimitivesNative.kt
@@ -5,7 +5,6 @@ package io.ktor.utils.io.bits
import kotlinx.cinterop.*
import kotlin.experimental.*
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadShortAt(offset: Int): Short {
assertIndex(offset, 2)
val pointer = pointer.plus(offset)!!
@@ -17,7 +16,6 @@ public actual inline fun Memory.loadShortAt(offset: Int): Short {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadShortAt(offset: Long): Short {
assertIndex(offset, 2)
val pointer = pointer.plus(offset)!!
@@ -29,7 +27,6 @@ public actual inline fun Memory.loadShortAt(offset: Long): Short {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadIntAt(offset: Int): Int {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -41,7 +38,6 @@ public actual inline fun Memory.loadIntAt(offset: Int): Int {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadIntAt(offset: Long): Int {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -53,7 +49,6 @@ public actual inline fun Memory.loadIntAt(offset: Long): Int {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadLongAt(offset: Int): Long {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -65,7 +60,6 @@ public actual inline fun Memory.loadLongAt(offset: Int): Long {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadLongAt(offset: Long): Long {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -77,7 +71,6 @@ public actual inline fun Memory.loadLongAt(offset: Long): Long {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadFloatAt(offset: Int): Float {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -89,7 +82,6 @@ public actual inline fun Memory.loadFloatAt(offset: Int): Float {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadFloatAt(offset: Long): Float {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -101,7 +93,6 @@ public actual inline fun Memory.loadFloatAt(offset: Long): Float {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadDoubleAt(offset: Int): Double {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -113,7 +104,6 @@ public actual inline fun Memory.loadDoubleAt(offset: Int): Double {
}
}
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
public actual inline fun Memory.loadDoubleAt(offset: Long): Double {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -128,7 +118,7 @@ public actual inline fun Memory.loadDoubleAt(offset: Long): Double {
/**
* Write regular signed 32bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeIntAt(offset: Int, value: Int) {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -143,7 +133,7 @@ public actual inline fun Memory.storeIntAt(offset: Int, value: Int) {
/**
* Write regular signed 32bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeIntAt(offset: Long, value: Int) {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -158,7 +148,7 @@ public actual inline fun Memory.storeIntAt(offset: Long, value: Int) {
/**
* Write short signed 16bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeShortAt(offset: Int, value: Short) {
assertIndex(offset, 2)
val pointer = pointer.plus(offset)!!
@@ -173,7 +163,7 @@ public actual inline fun Memory.storeShortAt(offset: Int, value: Short) {
/**
* Write short signed 16bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeShortAt(offset: Long, value: Short) {
assertIndex(offset, 2)
val pointer = pointer.plus(offset)!!
@@ -188,7 +178,7 @@ public actual inline fun Memory.storeShortAt(offset: Long, value: Short) {
/**
* Write short signed 64bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeLongAt(offset: Int, value: Long) {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -203,7 +193,7 @@ public actual inline fun Memory.storeLongAt(offset: Int, value: Long) {
/**
* Write short signed 64bit integer in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeLongAt(offset: Long, value: Long) {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -218,7 +208,7 @@ public actual inline fun Memory.storeLongAt(offset: Long, value: Long) {
/**
* Write short signed 32bit floating point number in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeFloatAt(offset: Int, value: Float) {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -233,7 +223,7 @@ public actual inline fun Memory.storeFloatAt(offset: Int, value: Float) {
/**
* Write short signed 32bit floating point number in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeFloatAt(offset: Long, value: Float) {
assertIndex(offset, 4)
val pointer = pointer.plus(offset)!!
@@ -248,7 +238,7 @@ public actual inline fun Memory.storeFloatAt(offset: Long, value: Float) {
/**
* Write short signed 64bit floating point number in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeDoubleAt(offset: Int, value: Double) {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -263,7 +253,7 @@ public actual inline fun Memory.storeDoubleAt(offset: Int, value: Double) {
/**
* Write short signed 64bit floating point number in the network byte order (Big Endian)
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual inline fun Memory.storeDoubleAt(offset: Long, value: Double) {
assertIndex(offset, 8)
val pointer = pointer.plus(offset)!!
@@ -275,14 +265,12 @@ public actual inline fun Memory.storeDoubleAt(offset: Long, value: Double) {
}
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun storeShortSlowAt(pointer: CPointer, value: Short) {
pointer[0] = (value.toInt() ushr 8).toByte()
pointer[1] = (value and 0xff).toByte()
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun storeIntSlowAt(pointer: CPointer, value: Int) {
pointer[0] = (value ushr 24).toByte()
@@ -291,7 +279,6 @@ internal inline fun storeIntSlowAt(pointer: CPointer, value: Int) {
pointer[3] = (value and 0xff).toByte()
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun storeLongSlowAt(pointer: CPointer, value: Long) {
pointer[0] = (value ushr 56).toByte()
@@ -304,25 +291,21 @@ internal inline fun storeLongSlowAt(pointer: CPointer, value: Long) {
pointer[7] = (value and 0xff).toByte()
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun storeFloatSlowAt(pointer: CPointer, value: Float) {
storeIntSlowAt(pointer, value.toRawBits())
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun storeDoubleSlowAt(pointer: CPointer, value: Double) {
storeLongSlowAt(pointer, value.toRawBits())
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun loadShortSlowAt(pointer: CPointer): Short {
return ((pointer[0].toInt() shl 8) or (pointer[1].toInt() and 0xff)).toShort()
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun loadIntSlowAt(pointer: CPointer): Int {
return (
@@ -333,7 +316,6 @@ internal inline fun loadIntSlowAt(pointer: CPointer): Int {
)
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun loadLongSlowAt(pointer: CPointer): Long {
return (
@@ -348,13 +330,11 @@ internal inline fun loadLongSlowAt(pointer: CPointer): Long {
)
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun loadFloatSlowAt(pointer: CPointer): Float {
return Float.fromBits(loadIntSlowAt(pointer))
}
-@OptIn(ExperimentalForeignApi::class)
@PublishedApi
internal inline fun loadDoubleSlowAt(pointer: CPointer): Double {
return Double.fromBits(loadLongSlowAt(pointer))
diff --git a/ktor-io/posix/src/io/ktor/utils/io/bits/PrimitiveArraysNative.kt b/ktor-io/posix/src/io/ktor/utils/io/bits/PrimitiveArraysNative.kt
index b7f4e95d4b2..94e19d8e483 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/bits/PrimitiveArraysNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/bits/PrimitiveArraysNative.kt
@@ -25,7 +25,7 @@ public actual fun Memory.loadShortArray(
* to the [destination] at [destinationOffset] interpreting numbers in the network order (Big Endian).
* @param destinationOffset items
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.loadShortArray(
offset: Long,
destination: ShortArray,
@@ -81,7 +81,7 @@ public actual fun Memory.loadIntArray(
* to the [destination] at [destinationOffset] interpreting numbers in the network order (Big Endian).
* @param destinationOffset items
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.loadIntArray(
offset: Long,
destination: IntArray,
@@ -141,7 +141,7 @@ public actual fun Memory.loadLongArray(
* to the [destination] at [destinationOffset] interpreting numbers in the network order (Big Endian).
* @param destinationOffset items
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.loadLongArray(
offset: Long,
destination: LongArray,
@@ -197,7 +197,7 @@ public actual fun Memory.loadFloatArray(
* to the [destination] at [destinationOffset] interpreting numbers in the network order (Big Endian).
* @param destinationOffset items
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.loadFloatArray(
offset: Long,
destination: FloatArray,
@@ -253,7 +253,7 @@ public actual fun Memory.loadDoubleArray(
* to the [destination] at [destinationOffset] interpreting numbers in the network order (Big Endian).
* @param destinationOffset items
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun Memory.loadDoubleArray(
offset: Long,
destination: DoubleArray,
@@ -309,7 +309,7 @@ public actual fun Memory.storeShortArray(
* interpreting numbers in the network order (Big Endian).
* @param sourceOffset items
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual fun Memory.storeShortArray(
offset: Long,
source: ShortArray,
@@ -355,7 +355,7 @@ public actual fun Memory.storeIntArray(
* interpreting numbers in the network order (Big Endian).
* @param sourceOffset items
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual fun Memory.storeIntArray(
offset: Long,
source: IntArray,
@@ -401,7 +401,7 @@ public actual fun Memory.storeLongArray(
* interpreting numbers in the network order (Big Endian).
* @param sourceOffset items
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual fun Memory.storeLongArray(
offset: Long,
source: LongArray,
@@ -447,7 +447,7 @@ public actual fun Memory.storeFloatArray(
* interpreting numbers in the network order (Big Endian).
* @param sourceOffset items
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual fun Memory.storeFloatArray(
offset: Long,
source: FloatArray,
@@ -493,7 +493,7 @@ public actual fun Memory.storeDoubleArray(
* interpreting numbers in the network order (Big Endian).
* @param sourceOffset items
*/
-@OptIn(ExperimentalForeignApi::class, ExperimentalNativeApi::class)
+
public actual fun Memory.storeDoubleArray(
offset: Long,
source: DoubleArray,
@@ -544,16 +544,13 @@ internal inline fun requireRange(offset: Long, length: Long, size: Long, name: S
}
}
-@OptIn(ExperimentalForeignApi::class)
internal inline fun Memory.isAlignedShort(offset: Long) = (pointer.toLong() + offset) and 0b1 == 0L
-@OptIn(ExperimentalForeignApi::class)
internal inline fun Memory.isAlignedInt(offset: Long) = (pointer.toLong() + offset) and 0b11 == 0L
-@OptIn(ExperimentalForeignApi::class)
internal inline fun Memory.isAlignedLong(offset: Long) = (pointer.toLong() + offset) and 0b111 == 0L
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun copy(
source: IntArray,
destinationPointer: CPointer,
@@ -565,7 +562,7 @@ private fun copy(
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun copy(
source: ShortArray,
destinationPointer: CPointer,
@@ -577,7 +574,7 @@ private fun copy(
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun copy(
source: LongArray,
destinationPointer: CPointer,
@@ -589,7 +586,7 @@ private fun copy(
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun copy(
source: FloatArray,
destinationPointer: CPointer,
@@ -601,7 +598,7 @@ private fun copy(
}
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun copy(
source: DoubleArray,
destinationPointer: CPointer,
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/BufferUtilsNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/BufferUtilsNative.kt
index 3ece97213fa..b6f43d25ac3 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/BufferUtilsNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/BufferUtilsNative.kt
@@ -10,25 +10,21 @@ import kotlin.contracts.*
@PublishedApi
internal val MAX_SIZE: size_t = size_t.MAX_VALUE
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun ChunkBuffer(ptr: CPointer<*>, lengthInBytes: Int, origin: ChunkBuffer?): ChunkBuffer {
return ChunkBuffer(Memory.of(ptr, lengthInBytes), origin, null)
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun ChunkBuffer(ptr: CPointer<*>, lengthInBytes: Long, origin: ChunkBuffer?): ChunkBuffer {
return ChunkBuffer(Memory.of(ptr, lengthInBytes), origin, null)
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.readFully(pointer: CPointer, offset: Int, length: Int) {
readFully(pointer, offset.toLong(), length)
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.readFully(pointer: CPointer, offset: Long, length: Int) {
requirePositiveIndex(offset, "offset")
@@ -38,13 +34,11 @@ public fun Buffer.readFully(pointer: CPointer, offset: Long, length: In
}
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.readAvailable(pointer: CPointer, offset: Int, length: Int): Int {
return readAvailable(pointer, offset.toLong(), length)
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.readAvailable(pointer: CPointer, offset: Long, length: Int): Int {
val available = readRemaining
@@ -54,7 +48,6 @@ public fun Buffer.readAvailable(pointer: CPointer, offset: Long, length
return resultSize
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.writeFully(pointer: CPointer, offset: Int, length: Int) {
requirePositiveIndex(offset, "offset")
@@ -65,7 +58,6 @@ public fun Buffer.writeFully(pointer: CPointer, offset: Int, length: In
}
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
public fun Buffer.writeFully(pointer: CPointer, offset: Long, length: Int) {
requirePositiveIndex(offset, "offset")
@@ -77,7 +69,7 @@ public fun Buffer.writeFully(pointer: CPointer, offset: Long, length: I
}
@Suppress("DEPRECATION")
-@OptIn(ExperimentalContracts::class, ExperimentalForeignApi::class)
+@OptIn(ExperimentalContracts::class)
public inline fun Buffer.readDirect(block: (CPointer) -> Int): Int {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
@@ -89,7 +81,7 @@ public inline fun Buffer.readDirect(block: (CPointer) -> Int): Int {
}
@Suppress("DEPRECATION")
-@OptIn(ExperimentalContracts::class, ExperimentalForeignApi::class)
+@OptIn(ExperimentalContracts::class)
public inline fun Buffer.writeDirect(block: (CPointer) -> Int): Int {
contract {
callsInPlace(block, InvocationKind.EXACTLY_ONCE)
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/BytePacketsNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/BytePacketsNative.kt
index 1829ef971b9..981d63c2f90 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/BytePacketsNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/BytePacketsNative.kt
@@ -7,7 +7,7 @@ import kotlinx.cinterop.*
* Read at most [limit] bytes to the specified [dst] address
* @return number of bytes copied
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun ByteReadPacket.readAvailable(dst: CPointer, limit: Int): Int =
readAsMuchAsPossible(dst, limit.toLong(), 0L).toInt()
@@ -15,7 +15,7 @@ public fun ByteReadPacket.readAvailable(dst: CPointer, limit: Int): Int
* Read at most [limit] bytes to the specified [dst] address
* @return number of bytes copied
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun ByteReadPacket.readAvailable(dst: CPointer, limit: Long): Long =
readAsMuchAsPossible(dst, limit, 0L)
@@ -23,7 +23,7 @@ public fun ByteReadPacket.readAvailable(dst: CPointer, limit: Long): Lo
* Read exactly [size] bytes to the specified [dst] address
* @return number of bytes copied
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun ByteReadPacket.readFully(dst: CPointer, size: Int): Int {
val rc = readAsMuchAsPossible(dst, size.toLong(), 0L)
if (rc != size.toLong()) {
@@ -36,14 +36,13 @@ public fun ByteReadPacket.readFully(dst: CPointer, size: Int): Int {
* Read exactly [size] bytes to the specified [dst] address
* @return number of bytes copied
*/
-@OptIn(ExperimentalForeignApi::class)
+
public fun ByteReadPacket.readFully(dst: CPointer, size: Long): Long {
val rc = readAsMuchAsPossible(dst, size, 0L)
if (rc != size) throw EOFException("Not enough data in packet to fill buffer: ${size - rc} more bytes required")
return rc
}
-@OptIn(ExperimentalForeignApi::class)
private tailrec fun ByteReadPacket.readAsMuchAsPossible(
buffer: CPointer,
destinationCapacity: Long,
@@ -71,7 +70,6 @@ private tailrec fun ByteReadPacket.readAsMuchAsPossible(
* Write all remaining [src] buffer bytes and change its position accordingly
*/
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
public fun BytePacketBuilder.writeFully(src: CPointer, size: Int) {
var remaining = size
var offset = 0
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/ByteReadPacket.kt b/ktor-io/posix/src/io/ktor/utils/io/core/ByteReadPacket.kt
index 6b5dd6e829b..fb6cb9f1a12 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/ByteReadPacket.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/ByteReadPacket.kt
@@ -7,7 +7,6 @@ import io.ktor.utils.io.core.internal.*
import io.ktor.utils.io.pool.*
import kotlinx.cinterop.*
-@OptIn(ExperimentalForeignApi::class)
public actual fun ByteReadPacket(
array: ByteArray,
offset: Int,
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/InputArraysNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/InputArraysNative.kt
index 921321ca8f8..651543ba513 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/InputArraysNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/InputArraysNative.kt
@@ -2,7 +2,6 @@ package io.ktor.utils.io.core
import kotlinx.cinterop.*
-@OptIn(ExperimentalForeignApi::class)
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "DEPRECATION")
public fun Input.readFully(dst: CPointer, offset: Int, length: Int) {
if (readAvailable(dst, offset, length) != length) {
@@ -10,7 +9,6 @@ public fun Input.readFully(dst: CPointer, offset: Int, length: Int) {
}
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "DEPRECATION")
public fun Input.readFully(dst: CPointer, offset: Long, length: Long) {
if (readAvailable(dst, offset, length) != length) {
@@ -18,7 +16,6 @@ public fun Input.readFully(dst: CPointer, offset: Long, length: Long) {
}
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "DEPRECATION")
public fun Input.readAvailable(dst: CPointer, offset: Int, length: Int): Int {
var bytesCopied = 0
@@ -33,7 +30,6 @@ public fun Input.readAvailable(dst: CPointer, offset: Int, length: Int)
return bytesCopied
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("EXTENSION_SHADOWED_BY_MEMBER", "DEPRECATION")
public fun Input.readAvailable(dst: CPointer, offset: Long, length: Long): Long {
var bytesCopied = 0L
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/OutputArraysNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/OutputArraysNative.kt
index adabb581b4d..c58826f1554 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/OutputArraysNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/OutputArraysNative.kt
@@ -5,13 +5,11 @@ package io.ktor.utils.io.core
import kotlinx.cinterop.*
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
public fun Output.writeFully(src: CPointer, offset: Int, length: Int) {
writeFully(src, offset.toLong(), length.toLong())
}
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
public fun Output.writeFully(src: CPointer, offset: Long, length: Long) {
require(length >= 0L)
require(offset >= 0L)
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/ScannerNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/ScannerNative.kt
index 31268ae6f81..109c89e30f0 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/ScannerNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/ScannerNative.kt
@@ -4,7 +4,6 @@ import kotlinx.cinterop.*
import platform.posix.*
@Suppress("DEPRECATION")
-@OptIn(ExperimentalForeignApi::class)
internal actual fun Buffer.discardUntilDelimiterImpl(delimiter: Byte): Int {
val content = content
var idx = readPosition
@@ -20,7 +19,6 @@ internal actual fun Buffer.discardUntilDelimiterImpl(delimiter: Byte): Int {
return idx - start
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
internal actual fun Buffer.discardUntilDelimitersImpl(delimiter1: Byte, delimiter2: Byte): Int {
val content = content
@@ -80,7 +78,7 @@ internal actual fun Buffer.readUntilDelimitersImpl(delimiter1: Byte, delimiter2:
return readUntilImpl({ it == delimiter1 || it == delimiter2 }, dst)
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
@Suppress("DEPRECATION")
private inline fun Buffer.readUntilImpl(
predicate: (Byte) -> Boolean,
@@ -113,7 +111,7 @@ private inline fun Buffer.readUntilImpl(
}
@Suppress("DEPRECATION")
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private inline fun Buffer.readUntilImpl(
predicate: (Byte) -> Boolean,
dst: Output
@@ -146,6 +144,5 @@ private inline fun Buffer.readUntilImpl(
return copiedTotal
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("DEPRECATION")
internal inline val Buffer.content: CPointer get() = memory.pointer
diff --git a/ktor-io/posix/src/io/ktor/utils/io/core/StringsNative.kt b/ktor-io/posix/src/io/ktor/utils/io/core/StringsNative.kt
index 29155ec042d..50104735b6d 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/core/StringsNative.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/core/StringsNative.kt
@@ -8,7 +8,7 @@ import kotlinx.cinterop.*
* Create an instance of [String] from the specified [bytes] range starting at [offset] and bytes [length]
* interpreting characters in the specified [charset].
*/
-@OptIn(ExperimentalForeignApi::class)
+
@Suppress("FunctionName")
public actual fun String(bytes: ByteArray, offset: Int, length: Int, charset: Charset): String {
if (length == 0 && offset <= bytes.size) return ""
diff --git a/ktor-io/posix/src/io/ktor/utils/io/errors/PosixErrors.kt b/ktor-io/posix/src/io/ktor/utils/io/errors/PosixErrors.kt
index a06907c2e8b..b0571d27c2d 100644
--- a/ktor-io/posix/src/io/ktor/utils/io/errors/PosixErrors.kt
+++ b/ktor-io/posix/src/io/ktor/utils/io/errors/PosixErrors.kt
@@ -72,7 +72,7 @@ public sealed class PosixException(public val errno: Int, message: String) : Exc
* @param posixFunctionName optional function name to be included to the exception message
* @return an instance of [PosixException] or it's subtype
*/
- @OptIn(ExperimentalForeignApi::class)
+
public fun forErrno(
errno: Int = platform.posix.errno,
posixFunctionName: String? = null
@@ -118,5 +118,4 @@ public sealed class PosixException(public val errno: Int, message: String) : Exc
internal fun PosixException.wrapIO(): IOException =
IOException("I/O operation failed due to posix error code $errno", this)
-@OptIn(ExperimentalForeignApi::class)
private fun posixErrorToString(errno: Int): String = strerror(errno)?.toKString() ?: "Unknown error code: $errno"
diff --git a/ktor-io/posix/test/io/ktor/utils/io/ByteChannelNativeTests.kt b/ktor-io/posix/test/io/ktor/utils/io/ByteChannelNativeTests.kt
index 7e76f90ad01..f917281f407 100644
--- a/ktor-io/posix/test/io/ktor/utils/io/ByteChannelNativeTests.kt
+++ b/ktor-io/posix/test/io/ktor/utils/io/ByteChannelNativeTests.kt
@@ -8,7 +8,7 @@ import kotlinx.cinterop.*
import kotlin.test.*
class ByteChannelNativeTests : ByteChannelTestBase(true) {
- @OptIn(ExperimentalForeignApi::class)
+
@Test
fun testCPointersReadWriteFully() = runTest {
val array = ByteArray(4)
@@ -30,7 +30,6 @@ class ByteChannelNativeTests : ByteChannelTestBase(true) {
assertTrue { array.contentEquals(result) }
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testCPointersReadWriteFullyWithShift() = runTest {
for (shift in 0..3) {
@@ -56,7 +55,6 @@ class ByteChannelNativeTests : ByteChannelTestBase(true) {
}
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testCPointersReadAvailable() = runTest {
val array = ByteArray(4)
diff --git a/ktor-io/posix/test/io/ktor/utils/io/BytePacketBuilderExtendedTest.kt b/ktor-io/posix/test/io/ktor/utils/io/BytePacketBuilderExtendedTest.kt
index 4a682a16421..b6c64701de7 100644
--- a/ktor-io/posix/test/io/ktor/utils/io/BytePacketBuilderExtendedTest.kt
+++ b/ktor-io/posix/test/io/ktor/utils/io/BytePacketBuilderExtendedTest.kt
@@ -11,10 +11,8 @@ import kotlin.test.*
class BytePacketBuilderExtendedTest : BytePacketBuildTest() {
override val pool = VerifyingChunkBufferPool()
- @OptIn(ExperimentalForeignApi::class)
private val buffer = nativeHeap.allocArray(8888)
- @OptIn(ExperimentalForeignApi::class)
@Test
fun smokeSingleBufferTestExtended() {
val p = buildPacket {
@@ -48,7 +46,6 @@ class BytePacketBuilderExtendedTest : BytePacketBuildTest() {
assertEquals("1|2|3", p.readUTF8Line())
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun smokeMultiBufferTestExtended() {
val p = buildPacket {
diff --git a/ktor-io/posix/test/io/ktor/utils/io/ChunkBufferNativeTest.kt b/ktor-io/posix/test/io/ktor/utils/io/ChunkBufferNativeTest.kt
index 57de09940e3..648943883c1 100644
--- a/ktor-io/posix/test/io/ktor/utils/io/ChunkBufferNativeTest.kt
+++ b/ktor-io/posix/test/io/ktor/utils/io/ChunkBufferNativeTest.kt
@@ -13,7 +13,6 @@ class ChunkBufferNativeTest {
buffer.release(ChunkBuffer.Pool)
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testReadDirectOnEmpty() {
var invoked: Boolean
@@ -26,7 +25,6 @@ class ChunkBufferNativeTest {
assertTrue(invoked)
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testReadDirectNegativeResult() {
assertFails {
@@ -36,7 +34,6 @@ class ChunkBufferNativeTest {
}
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testReadDirectTooManyBytesResult() {
assertFails {
@@ -46,7 +43,6 @@ class ChunkBufferNativeTest {
}
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testReadDirect() {
var result: Int
@@ -62,7 +58,6 @@ class ChunkBufferNativeTest {
assertEquals(8, buffer.readByte().toInt())
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testReadDirectAtEnd() {
while (buffer.writeRemaining > 0) {
@@ -82,7 +77,6 @@ class ChunkBufferNativeTest {
}
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testWriteDirect() {
buffer.writeDirect { ptr ->
@@ -98,7 +92,6 @@ class ChunkBufferNativeTest {
assertEquals(2, buffer.readByte().toInt())
}
- @OptIn(ExperimentalForeignApi::class)
@Test
fun testWriteDirectOnFull() {
val size = buffer.writeRemaining
diff --git a/ktor-io/posix/test/io/ktor/utils/io/PosixIoTest.kt b/ktor-io/posix/test/io/ktor/utils/io/PosixIoTest.kt
index 98e42e077a3..53966d67dc2 100644
--- a/ktor-io/posix/test/io/ktor/utils/io/PosixIoTest.kt
+++ b/ktor-io/posix/test/io/ktor/utils/io/PosixIoTest.kt
@@ -28,14 +28,12 @@ class PosixIoTest {
unlink(filename)
}
- @OptIn(ExperimentalForeignApi::class)
@Suppress("unused")
internal fun Int.checkError(action: String = ""): Int = when {
this < 0 -> memScoped { throw PosixException.forErrno(posixFunctionName = action) }
else -> this
}
- @OptIn(ExperimentalForeignApi::class)
@Suppress("unused")
internal fun Long.checkError(action: String = ""): Long = when {
this < 0 -> memScoped { throw PosixException.forErrno(posixFunctionName = action) }
@@ -44,7 +42,6 @@ class PosixIoTest {
private val ZERO: size_t = 0u
- @OptIn(ExperimentalForeignApi::class)
@Suppress("unused")
internal fun size_t.checkError(action: String = ""): size_t = when (this) {
ZERO -> errno.let { errno ->
diff --git a/ktor-network/api/ktor-network.api b/ktor-network/api/ktor-network.api
index 004c051be68..d150bccff29 100644
--- a/ktor-network/api/ktor-network.api
+++ b/ktor-network/api/ktor-network.api
@@ -29,7 +29,6 @@ public final class io/ktor/network/selector/SelectInterest : java/lang/Enum {
public static final field Companion Lio/ktor/network/selector/SelectInterest$Companion;
public static final field READ Lio/ktor/network/selector/SelectInterest;
public static final field WRITE Lio/ktor/network/selector/SelectInterest;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getFlag ()I
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/selector/SelectInterest;
public static fun values ()[Lio/ktor/network/selector/SelectInterest;
diff --git a/ktor-network/darwin/src/io/ktor/network/selector/SelectUtilsDarwin.kt b/ktor-network/darwin/src/io/ktor/network/selector/SelectUtilsDarwin.kt
index 5ead6b355d9..bad6054f87d 100644
--- a/ktor-network/darwin/src/io/ktor/network/selector/SelectUtilsDarwin.kt
+++ b/ktor-network/darwin/src/io/ktor/network/selector/SelectUtilsDarwin.kt
@@ -8,7 +8,6 @@ import kotlinx.cinterop.*
import platform.darwin.*
import kotlin.Byte
-@OptIn(ExperimentalForeignApi::class)
internal actual fun inetNtopBridge(
type: Int,
address: CPointer<*>,
diff --git a/ktor-network/darwin/src/io/ktor/network/util/SocketUtilsDarwin.kt b/ktor-network/darwin/src/io/ktor/network/util/SocketUtilsDarwin.kt
index ce0f0d18246..c83dcbf7695 100644
--- a/ktor-network/darwin/src/io/ktor/network/util/SocketUtilsDarwin.kt
+++ b/ktor-network/darwin/src/io/ktor/network/util/SocketUtilsDarwin.kt
@@ -8,7 +8,6 @@ import kotlinx.cinterop.ByteVar
import platform.darwin.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun ktor_inet_ntop(
family: Int,
src: CValuesRef<*>?,
diff --git a/ktor-network/ios/src/io/ktor/network/util/SocketUtilsIos.kt b/ktor-network/ios/src/io/ktor/network/util/SocketUtilsIos.kt
index 56192cd3cb5..7f38167cdaf 100644
--- a/ktor-network/ios/src/io/ktor/network/util/SocketUtilsIos.kt
+++ b/ktor-network/ios/src/io/ktor/network/util/SocketUtilsIos.kt
@@ -13,7 +13,6 @@ internal actual fun unpack_sockaddr_un(
error("Address ${sockaddr.sa_family} is not supported on ios")
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-network/ktor-network-tls/api/ktor-network-tls.api b/ktor-network/ktor-network-tls/api/ktor-network-tls.api
index a9aa8c1267b..fcf0749c678 100644
--- a/ktor-network/ktor-network-tls/api/ktor-network-tls.api
+++ b/ktor-network/ktor-network-tls/api/ktor-network-tls.api
@@ -59,7 +59,6 @@ public final class io/ktor/network/tls/CipherSuite {
public final class io/ktor/network/tls/CipherType : java/lang/Enum {
public static final field CBC Lio/ktor/network/tls/CipherType;
public static final field GCM Lio/ktor/network/tls/CipherType;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/CipherType;
public static fun values ()[Lio/ktor/network/tls/CipherType;
}
@@ -113,7 +112,6 @@ public final class io/ktor/network/tls/OIDKt {
public final class io/ktor/network/tls/SecretExchangeType : java/lang/Enum {
public static final field ECDHE Lio/ktor/network/tls/SecretExchangeType;
public static final field RSA Lio/ktor/network/tls/SecretExchangeType;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getJvmName ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/SecretExchangeType;
public static fun values ()[Lio/ktor/network/tls/SecretExchangeType;
@@ -125,7 +123,6 @@ public final class io/ktor/network/tls/ServerKeyExchangeType : java/lang/Enum {
public static final field ExplicitPrime Lio/ktor/network/tls/ServerKeyExchangeType;
public static final field NamedCurve Lio/ktor/network/tls/ServerKeyExchangeType;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/ServerKeyExchangeType;
public static fun values ()[Lio/ktor/network/tls/ServerKeyExchangeType;
}
@@ -139,7 +136,6 @@ public final class io/ktor/network/tls/TLSAlertLevel : java/lang/Enum {
public static final field FATAL Lio/ktor/network/tls/TLSAlertLevel;
public static final field WARNING Lio/ktor/network/tls/TLSAlertLevel;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/TLSAlertLevel;
public static fun values ()[Lio/ktor/network/tls/TLSAlertLevel;
}
@@ -176,7 +172,6 @@ public final class io/ktor/network/tls/TLSAlertType : java/lang/Enum {
public static final field UnsupportedExtension Lio/ktor/network/tls/TLSAlertType;
public static final field UserCanceled Lio/ktor/network/tls/TLSAlertType;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/TLSAlertType;
public static fun values ()[Lio/ktor/network/tls/TLSAlertType;
}
@@ -235,7 +230,6 @@ public final class io/ktor/network/tls/TLSHandshakeType : java/lang/Enum {
public static final field ServerHello Lio/ktor/network/tls/TLSHandshakeType;
public static final field ServerKeyExchange Lio/ktor/network/tls/TLSHandshakeType;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/TLSHandshakeType;
public static fun values ()[Lio/ktor/network/tls/TLSHandshakeType;
}
@@ -258,7 +252,6 @@ public final class io/ktor/network/tls/TLSRecordType : java/lang/Enum {
public static final field Companion Lio/ktor/network/tls/TLSRecordType$Companion;
public static final field Handshake Lio/ktor/network/tls/TLSRecordType;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/TLSRecordType;
public static fun values ()[Lio/ktor/network/tls/TLSRecordType;
}
@@ -274,7 +267,6 @@ public final class io/ktor/network/tls/TLSVersion : java/lang/Enum {
public static final field TLS11 Lio/ktor/network/tls/TLSVersion;
public static final field TLS12 Lio/ktor/network/tls/TLSVersion;
public final fun getCode ()I
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/TLSVersion;
public static fun values ()[Lio/ktor/network/tls/TLSVersion;
}
@@ -294,7 +286,6 @@ public final class io/ktor/network/tls/extensions/HashAlgorithm : java/lang/Enum
public static final field SHA384 Lio/ktor/network/tls/extensions/HashAlgorithm;
public static final field SHA512 Lio/ktor/network/tls/extensions/HashAlgorithm;
public final fun getCode ()B
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getMacName ()Ljava/lang/String;
public final fun getOpenSSLName ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/extensions/HashAlgorithm;
@@ -354,7 +345,6 @@ public final class io/ktor/network/tls/extensions/NamedCurve : java/lang/Enum {
public static final field sect571k1 Lio/ktor/network/tls/extensions/NamedCurve;
public static final field sect571r1 Lio/ktor/network/tls/extensions/NamedCurve;
public final fun getCode ()S
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getFieldSize ()I
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/extensions/NamedCurve;
public static fun values ()[Lio/ktor/network/tls/extensions/NamedCurve;
@@ -373,7 +363,6 @@ public final class io/ktor/network/tls/extensions/PointFormat : java/lang/Enum {
public static final field ANSIX962_COMPRESSED_PRIME Lio/ktor/network/tls/extensions/PointFormat;
public static final field UNCOMPRESSED Lio/ktor/network/tls/extensions/PointFormat;
public final fun getCode ()B
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/extensions/PointFormat;
public static fun values ()[Lio/ktor/network/tls/extensions/PointFormat;
}
@@ -391,7 +380,6 @@ public final class io/ktor/network/tls/extensions/SignatureAlgorithm : java/lang
public static final field ED448 Lio/ktor/network/tls/extensions/SignatureAlgorithm;
public static final field RSA Lio/ktor/network/tls/extensions/SignatureAlgorithm;
public final fun getCode ()B
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/extensions/SignatureAlgorithm;
public static fun values ()[Lio/ktor/network/tls/extensions/SignatureAlgorithm;
}
@@ -417,7 +405,6 @@ public final class io/ktor/network/tls/extensions/TLSExtensionType : java/lang/E
public static final field TRUNCATED_HMAC Lio/ktor/network/tls/extensions/TLSExtensionType;
public static final field TRUSTED_CA_KEYS Lio/ktor/network/tls/extensions/TLSExtensionType;
public final fun getCode ()S
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/extensions/TLSExtensionType;
public static fun values ()[Lio/ktor/network/tls/extensions/TLSExtensionType;
}
diff --git a/ktor-network/ktor-network-tls/ktor-network-tls-certificates/api/ktor-network-tls-certificates.api b/ktor-network/ktor-network-tls/ktor-network-tls-certificates/api/ktor-network-tls-certificates.api
index faed41be721..52cbb0dad6d 100644
--- a/ktor-network/ktor-network-tls/ktor-network-tls-certificates/api/ktor-network-tls-certificates.api
+++ b/ktor-network/ktor-network-tls/ktor-network-tls-certificates/api/ktor-network-tls-certificates.api
@@ -45,7 +45,6 @@ public final class io/ktor/network/tls/certificates/KeyType : java/lang/Enum {
public static final field CA Lio/ktor/network/tls/certificates/KeyType;
public static final field Client Lio/ktor/network/tls/certificates/KeyType;
public static final field Server Lio/ktor/network/tls/certificates/KeyType;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/network/tls/certificates/KeyType;
public static fun values ()[Lio/ktor/network/tls/certificates/KeyType;
}
diff --git a/ktor-network/linux/src/io/ktor/network/selector/SelectUtilsLinux.kt b/ktor-network/linux/src/io/ktor/network/selector/SelectUtilsLinux.kt
index e0257341344..91e7a6da92f 100644
--- a/ktor-network/linux/src/io/ktor/network/selector/SelectUtilsLinux.kt
+++ b/ktor-network/linux/src/io/ktor/network/selector/SelectUtilsLinux.kt
@@ -7,7 +7,6 @@ package io.ktor.network.selector
import kotlinx.cinterop.*
import platform.linux.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun inetNtopBridge(
type: Int,
address: CPointer<*>,
diff --git a/ktor-network/linux/src/io/ktor/network/util/SocketUtilsLinux.kt b/ktor-network/linux/src/io/ktor/network/util/SocketUtilsLinux.kt
index 16217dc0560..e1584ce9aa4 100644
--- a/ktor-network/linux/src/io/ktor/network/util/SocketUtilsLinux.kt
+++ b/ktor-network/linux/src/io/ktor/network/util/SocketUtilsLinux.kt
@@ -8,7 +8,6 @@ import kotlinx.cinterop.*
import platform.linux.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun ktor_inet_ntop(
family: Int,
src: CValuesRef<*>?,
@@ -16,7 +15,6 @@ internal actual fun ktor_inet_ntop(
size: socklen_t
): CPointer? = inet_ntop(family, src, dst, size)
-@OptIn(ExperimentalForeignApi::class)
internal actual fun unpack_sockaddr_un(
sockaddr: sockaddr,
block: (family: UShort, path: String) -> T
@@ -25,7 +23,6 @@ internal actual fun unpack_sockaddr_un(
return block(address.sun_family, address.sun_path.toKString())
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-network/macos/src/io/ktor/network/util/SocketUtilsMacos.kt b/ktor-network/macos/src/io/ktor/network/util/SocketUtilsMacos.kt
index a3c439ee97d..3247ab62aa5 100644
--- a/ktor-network/macos/src/io/ktor/network/util/SocketUtilsMacos.kt
+++ b/ktor-network/macos/src/io/ktor/network/util/SocketUtilsMacos.kt
@@ -7,7 +7,6 @@ import kotlinx.cinterop.*
import platform.osx.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun unpack_sockaddr_un(
sockaddr: sockaddr,
block: (family: UShort, path: String) -> T
@@ -16,7 +15,6 @@ internal actual fun unpack_sockaddr_un(
return block(address.sun_family.convert(), address.sun_path.toKString())
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-network/nix/src/io/ktor/network/selector/SelectUtils.kt b/ktor-network/nix/src/io/ktor/network/selector/SelectUtils.kt
index 9785248ac39..24de44ce7c6 100644
--- a/ktor-network/nix/src/io/ktor/network/selector/SelectUtils.kt
+++ b/ktor-network/nix/src/io/ktor/network/selector/SelectUtils.kt
@@ -14,7 +14,6 @@ import platform.posix.*
import kotlin.coroutines.*
import kotlin.math.*
-@OptIn(ExperimentalForeignApi::class)
internal expect fun inetNtopBridge(type: Int, address: CPointer<*>, addressOf: CPointer<*>, size: Int)
@OptIn(InternalAPI::class)
@@ -61,7 +60,6 @@ internal class SelectorHelper {
wakeupSignal.signal()
}
- @OptIn(ExperimentalForeignApi::class)
private fun selectionLoop() {
val readSet = select_create_fd_set()
val writeSet = select_create_fd_set()
@@ -103,7 +101,6 @@ internal class SelectorHelper {
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun fillHandlers(
watchSet: MutableSet,
readSet: CValue,
@@ -129,7 +126,6 @@ internal class SelectorHelper {
return maxDescriptor
}
- @OptIn(ExperimentalForeignApi::class)
private fun addInterest(
event: EventInfo,
readSet: CValue,
@@ -145,7 +141,6 @@ internal class SelectorHelper {
check(select_fd_isset(event.descriptor, errorSet) != 0)
}
- @OptIn(ExperimentalForeignApi::class)
private fun processSelectedEvents(
watchSet: MutableSet,
closeSet: MutableSet,
@@ -193,7 +188,6 @@ internal class SelectorHelper {
completed.clear()
}
- @OptIn(ExperimentalForeignApi::class)
private fun descriptorSetByInterestKind(
event: EventInfo,
readSet: CValue,
diff --git a/ktor-network/nix/src/io/ktor/network/selector/SignalPoint.kt b/ktor-network/nix/src/io/ktor/network/selector/SignalPoint.kt
index 631382d63c1..b5218e6ad5c 100644
--- a/ktor-network/nix/src/io/ktor/network/selector/SignalPoint.kt
+++ b/ktor-network/nix/src/io/ktor/network/selector/SignalPoint.kt
@@ -12,7 +12,6 @@ import kotlinx.atomicfu.locks.*
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal class SignalPoint : Closeable {
private val readDescriptor: Int
private val writeDescriptor: Int
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/CIOReader.kt b/ktor-network/nix/src/io/ktor/network/sockets/CIOReader.kt
index 3cd9d59d6d2..c48e4c6a82c 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/CIOReader.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/CIOReader.kt
@@ -11,7 +11,7 @@ import kotlinx.cinterop.*
import kotlinx.coroutines.*
import platform.posix.*
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun CoroutineScope.attachForReadingImpl(
userChannel: ByteChannel,
descriptor: Int,
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/CIOWriter.kt b/ktor-network/nix/src/io/ktor/network/sockets/CIOWriter.kt
index bc41084fa7f..c754910722a 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/CIOWriter.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/CIOWriter.kt
@@ -12,7 +12,7 @@ import kotlinx.coroutines.*
import platform.posix.*
import kotlin.math.*
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun CoroutineScope.attachForWritingImpl(
userChannel: ByteChannel,
descriptor: Int,
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/ConnectUtilsNative.kt b/ktor-network/nix/src/io/ktor/network/sockets/ConnectUtilsNative.kt
index 1908f44cb41..a8f3bb4faa6 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/ConnectUtilsNative.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/ConnectUtilsNative.kt
@@ -11,7 +11,7 @@ import platform.posix.*
private const val DEFAULT_BACKLOG_SIZE = 50
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual suspend fun connect(
selector: SelectorManager,
remoteAddress: SocketAddress,
@@ -43,7 +43,7 @@ internal actual suspend fun connect(
error("Failed to connect to $remoteAddress.")
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun bind(
selector: SelectorManager,
localAddress: SocketAddress?,
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/DatagramSendChannel.kt b/ktor-network/nix/src/io/ktor/network/sockets/DatagramSendChannel.kt
index 9686c2df76f..86e823e9b58 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/DatagramSendChannel.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/DatagramSendChannel.kt
@@ -103,7 +103,6 @@ internal class DatagramSendChannel(
}
}
- @OptIn(ExperimentalForeignApi::class)
private fun sento(datagram: Datagram, bytes: ByteArray): Int {
var bytesWritten: Int? = null
bytes.usePinned { pinned ->
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/DatagramSocketNative.kt b/ktor-network/nix/src/io/ktor/network/sockets/DatagramSocketNative.kt
index 6f878f5fa84..991aaf65496 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/DatagramSocketNative.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/DatagramSocketNative.kt
@@ -82,7 +82,7 @@ internal class DatagramSocketNative(
}
}
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
private fun tryReadDatagram(): Datagram? = memScoped {
val clientAddress = alloc()
val clientAddressLength: UIntVarOf = alloc()
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/NativeSocketOptions.kt b/ktor-network/nix/src/io/ktor/network/sockets/NativeSocketOptions.kt
index cbb20c279d7..42cd06fa67f 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/NativeSocketOptions.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/NativeSocketOptions.kt
@@ -20,7 +20,6 @@ internal fun assignOptions(descriptor: Int, options: SocketOptions) {
}
}
-@OptIn(ExperimentalForeignApi::class)
private fun setSocketFlag(
descriptor: Int,
optionName: Int,
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/TCPServerSocketNative.kt b/ktor-network/nix/src/io/ktor/network/sockets/TCPServerSocketNative.kt
index cb2a0d249b6..9c26c995484 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/TCPServerSocketNative.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/TCPServerSocketNative.kt
@@ -11,7 +11,6 @@ import kotlinx.coroutines.*
import platform.posix.*
import kotlin.coroutines.*
-@OptIn(ExperimentalForeignApi::class)
internal class TCPServerSocketNative(
private val descriptor: Int,
private val selectorManager: SelectorManager,
diff --git a/ktor-network/nix/src/io/ktor/network/sockets/UDPSocketBuilderNative.kt b/ktor-network/nix/src/io/ktor/network/sockets/UDPSocketBuilderNative.kt
index dd6210b211b..a23df227400 100644
--- a/ktor-network/nix/src/io/ktor/network/sockets/UDPSocketBuilderNative.kt
+++ b/ktor-network/nix/src/io/ktor/network/sockets/UDPSocketBuilderNative.kt
@@ -9,7 +9,7 @@ import io.ktor.network.util.*
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun UDPSocketBuilder.Companion.connectUDP(
selector: SelectorManager,
remoteAddress: SocketAddress,
@@ -38,7 +38,7 @@ internal actual fun UDPSocketBuilder.Companion.connectUDP(
)
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun UDPSocketBuilder.Companion.bindUDP(
selector: SelectorManager,
localAddress: SocketAddress?,
diff --git a/ktor-network/nix/src/io/ktor/network/util/NativeSocketAddress.kt b/ktor-network/nix/src/io/ktor/network/util/NativeSocketAddress.kt
index 03f3aec1862..9ecf378c486 100644
--- a/ktor-network/nix/src/io/ktor/network/util/NativeSocketAddress.kt
+++ b/ktor-network/nix/src/io/ktor/network/util/NativeSocketAddress.kt
@@ -13,7 +13,7 @@ import platform.posix.*
*/
@OptIn(UnsafeNumber::class)
internal sealed class NativeSocketAddress(val family: sa_family_t) {
- @OptIn(ExperimentalForeignApi::class)
+
internal abstract fun nativeAddress(block: (address: CPointer, size: socklen_t) -> Unit)
}
@@ -38,7 +38,6 @@ internal class NativeIPv4SocketAddress(
override fun toString(): String = "NativeIPv4SocketAddress[$ipString:$port]"
- @ExperimentalForeignApi
override fun nativeAddress(block: (address: CPointer, size: socklen_t) -> Unit) {
cValue {
sin_addr.s_addr = address
@@ -49,7 +48,6 @@ internal class NativeIPv4SocketAddress(
}
}
- @OptIn(ExperimentalForeignApi::class)
override val ipString: String
get() = memScoped {
val string = allocArray(INET_ADDRSTRLEN)
@@ -74,7 +72,6 @@ internal class NativeIPv6SocketAddress(
private val flowInfo: uint32_t,
private val scopeId: uint32_t
) : NativeInetSocketAddress(family, port) {
- @ExperimentalForeignApi
override fun nativeAddress(block: (address: CPointer, size: socklen_t) -> Unit) {
cValue {
sin6_family = family
@@ -86,7 +83,6 @@ internal class NativeIPv6SocketAddress(
}
}
- @OptIn(ExperimentalForeignApi::class)
override val ipString: String
get() = memScoped {
val string = allocArray(INET6_ADDRSTRLEN)
@@ -108,7 +104,6 @@ internal class NativeUnixSocketAddress(
family: sa_family_t,
val path: String,
) : NativeSocketAddress(family) {
- @ExperimentalForeignApi
override fun nativeAddress(block: (address: CPointer, size: socklen_t) -> Unit) {
pack_sockaddr_un(family.convert(), path) { address, size ->
block(address, size)
diff --git a/ktor-network/nix/src/io/ktor/network/util/SocketAddressUtils.kt b/ktor-network/nix/src/io/ktor/network/util/SocketAddressUtils.kt
index 0b76af75dce..b62649dac0a 100644
--- a/ktor-network/nix/src/io/ktor/network/util/SocketAddressUtils.kt
+++ b/ktor-network/nix/src/io/ktor/network/util/SocketAddressUtils.kt
@@ -13,7 +13,7 @@ internal val SocketAddress.address: NativeSocketAddress get() {
return explicitAddress as? NativeSocketAddress ?: error("Failed to resolve address for $this")
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun SocketAddress.resolve(): List = when (this) {
is InetSocketAddress -> getAddressInfo(hostname, port)
is UnixSocketAddress -> listOf(NativeUnixSocketAddress(AF_UNIX.convert(), path))
diff --git a/ktor-network/nix/src/io/ktor/network/util/SocketUtils.kt b/ktor-network/nix/src/io/ktor/network/util/SocketUtils.kt
index 3c5604435cf..dba5b88f538 100644
--- a/ktor-network/nix/src/io/ktor/network/util/SocketUtils.kt
+++ b/ktor-network/nix/src/io/ktor/network/util/SocketUtils.kt
@@ -8,7 +8,6 @@ import io.ktor.utils.io.bits.*
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal fun getAddressInfo(
hostname: String,
portInfo: Int
@@ -28,7 +27,6 @@ internal fun getAddressInfo(
return result.pointed.toIpList()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun getLocalAddress(descriptor: Int): NativeSocketAddress = memScoped {
val address = alloc()
val length: UIntVarOf = alloc()
@@ -39,7 +37,6 @@ internal fun getLocalAddress(descriptor: Int): NativeSocketAddress = memScoped {
return@memScoped address.reinterpret().toNativeSocketAddress()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun getRemoteAddress(descriptor: Int): NativeSocketAddress = memScoped {
val address = alloc()
val length: UIntVarOf = alloc()
@@ -50,7 +47,6 @@ internal fun getRemoteAddress(descriptor: Int): NativeSocketAddress = memScoped
return@memScoped address.reinterpret().toNativeSocketAddress()
}
-@OptIn(ExperimentalForeignApi::class)
internal fun addrinfo?.toIpList(): List {
var current: addrinfo? = this
val result = mutableListOf()
@@ -63,7 +59,7 @@ internal fun addrinfo?.toIpList(): List {
return result
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal fun sockaddr.toNativeSocketAddress(): NativeSocketAddress = when (sa_family.toInt()) {
AF_INET -> {
val address = ptr.reinterpret().pointed
@@ -97,7 +93,6 @@ internal fun hostToNetworkOrder(value: UShort): UShort {
return value.reverseByteOrder()
}
-@OptIn(ExperimentalForeignApi::class)
internal expect fun ktor_inet_ntop(
family: Int,
src: CValuesRef<*>?,
@@ -107,7 +102,6 @@ internal expect fun ktor_inet_ntop(
internal expect fun unpack_sockaddr_un(sockaddr: sockaddr, block: (family: UShort, path: String) -> T): T
-@OptIn(ExperimentalForeignApi::class)
internal expect fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-network/tvos/src/io/ktor/network/util/SocketUtilsTvos.kt b/ktor-network/tvos/src/io/ktor/network/util/SocketUtilsTvos.kt
index 33725ad7923..c1c637138fc 100644
--- a/ktor-network/tvos/src/io/ktor/network/util/SocketUtilsTvos.kt
+++ b/ktor-network/tvos/src/io/ktor/network/util/SocketUtilsTvos.kt
@@ -13,7 +13,6 @@ internal actual fun unpack_sockaddr_un(
error("Address ${sockaddr.sa_family} is not supported on tvos")
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-network/watchos/src/io/ktor/network/util/SocketUtilsWatchos.kt b/ktor-network/watchos/src/io/ktor/network/util/SocketUtilsWatchos.kt
index 97f84b0a1a8..6cb4094dbf6 100644
--- a/ktor-network/watchos/src/io/ktor/network/util/SocketUtilsWatchos.kt
+++ b/ktor-network/watchos/src/io/ktor/network/util/SocketUtilsWatchos.kt
@@ -13,7 +13,6 @@ internal actual fun unpack_sockaddr_un(
error("Address ${sockaddr.sa_family} is not supported on watchos")
}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun pack_sockaddr_un(
family: UShort,
path: String,
diff --git a/ktor-server/ktor-server-cio/jvmAndNix/test/io/ktor/tests/server/cio/RAWExample.kt b/ktor-server/ktor-server-cio/jvmAndNix/test/io/ktor/tests/server/cio/RAWExample.kt
index 20fbe853444..b01edff5252 100644
--- a/ktor-server/ktor-server-cio/jvmAndNix/test/io/ktor/tests/server/cio/RAWExample.kt
+++ b/ktor-server/ktor-server-cio/jvmAndNix/test/io/ktor/tests/server/cio/RAWExample.kt
@@ -12,7 +12,7 @@ import io.ktor.util.date.*
import io.ktor.utils.io.*
import io.ktor.utils.io.core.*
import kotlinx.coroutines.*
-import kotlin.concurrent.*
+import kotlin.jvm.*
@Volatile
private var cachedDateText: String = GMTDate().toHttpDate()
diff --git a/ktor-server/ktor-server-config-yaml/nix/src/io/ktor/server/config/yaml/YamlConfigNix.kt b/ktor-server/ktor-server-config-yaml/nix/src/io/ktor/server/config/yaml/YamlConfigNix.kt
index a1110ba8188..09d59ed220a 100644
--- a/ktor-server/ktor-server-config-yaml/nix/src/io/ktor/server/config/yaml/YamlConfigNix.kt
+++ b/ktor-server/ktor-server-config-yaml/nix/src/io/ktor/server/config/yaml/YamlConfigNix.kt
@@ -39,7 +39,6 @@ public actual fun YamlConfig(path: String?): YamlConfig? {
return YamlConfig(yaml).apply { checkEnvironmentVariables() }
}
-@OptIn(ExperimentalForeignApi::class)
private fun readFile(path: String): String {
val fileDescriptor = fopen(path, "rb") ?: throw ApplicationConfigurationException("Can not read $path")
val bytes = ByteArrayPool.borrow()
@@ -63,7 +62,7 @@ private fun readFile(path: String): String {
return packet.readText()
}
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
private fun CPointer.readFileChunk(
bytes: ByteArray,
size: Int
@@ -71,5 +70,4 @@ private fun CPointer.readFileChunk(
fread(pinned.addressOf(0), 1.convert(), size.convert(), this)
}.convert()
-@OptIn(ExperimentalForeignApi::class)
internal actual fun getEnvironmentValue(key: String): String? = getenv(key)?.toKString()
diff --git a/ktor-server/ktor-server-config-yaml/nix/test/YamlConfigTestNix.kt b/ktor-server/ktor-server-config-yaml/nix/test/YamlConfigTestNix.kt
index 8736a154fc5..e39ccd2d9bc 100644
--- a/ktor-server/ktor-server-config-yaml/nix/test/YamlConfigTestNix.kt
+++ b/ktor-server/ktor-server-config-yaml/nix/test/YamlConfigTestNix.kt
@@ -77,7 +77,7 @@ class YamlConfigTestNix {
return result
}
- @OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+ @OptIn(UnsafeNumber::class)
private fun writeFile(path: String, content: String) {
val file = fopen(path, "w")
val bytes = content.toByteArray()
diff --git a/ktor-server/ktor-server-core/api/ktor-server-core.api b/ktor-server/ktor-server-core/api/ktor-server-core.api
index b0734a3d21c..d97da6329e6 100644
--- a/ktor-server/ktor-server-core/api/ktor-server-core.api
+++ b/ktor-server/ktor-server-core/api/ktor-server-core.api
@@ -356,7 +356,6 @@ public final class io/ktor/server/http/content/CompressedFileType : java/lang/En
public static final field GZIP Lio/ktor/server/http/content/CompressedFileType;
public final fun file (Ljava/io/File;)Ljava/io/File;
public final fun getEncoding ()Ljava/lang/String;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getExtension ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/server/http/content/CompressedFileType;
public static fun values ()[Lio/ktor/server/http/content/CompressedFileType;
@@ -1308,7 +1307,6 @@ public final class io/ktor/server/routing/RoutingPathSegment {
public final class io/ktor/server/routing/RoutingPathSegmentKind : java/lang/Enum {
public static final field Constant Lio/ktor/server/routing/RoutingPathSegmentKind;
public static final field Parameter Lio/ktor/server/routing/RoutingPathSegmentKind;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/server/routing/RoutingPathSegmentKind;
public static fun values ()[Lio/ktor/server/routing/RoutingPathSegmentKind;
}
diff --git a/ktor-server/ktor-server-core/nix/src/io/ktor/server/config/ConfigLoadersNix.kt b/ktor-server/ktor-server-core/nix/src/io/ktor/server/config/ConfigLoadersNix.kt
index c78b7f9da25..0ebef3d95fe 100644
--- a/ktor-server/ktor-server-core/nix/src/io/ktor/server/config/ConfigLoadersNix.kt
+++ b/ktor-server/ktor-server-core/nix/src/io/ktor/server/config/ConfigLoadersNix.kt
@@ -12,7 +12,6 @@ internal actual val CONFIG_PATH: List get() = buildList {
fromEnv("CONFIG_FILE")?.let { add(it) }
}
-@OptIn(ExperimentalForeignApi::class)
private fun fromEnv(name: String): String? = getenv(name)?.toKString()
/**
diff --git a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/EnvironmentUtilsNix.kt b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/EnvironmentUtilsNix.kt
index 6c2806ccf9b..d68e2b6217a 100644
--- a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/EnvironmentUtilsNix.kt
+++ b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/EnvironmentUtilsNix.kt
@@ -21,7 +21,6 @@ internal actual fun ApplicationEngineEnvironmentBuilder.configureSSLConnectors(
internal actual fun ApplicationEngineEnvironmentBuilder.configurePlatformProperties(args: Array) {}
-@OptIn(ExperimentalForeignApi::class)
internal actual fun getConfigFromEnvironment(): ApplicationConfig {
var index = 0
val config = MapApplicationConfig()
diff --git a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ServerEngineUtilsNix.kt b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ServerEngineUtilsNix.kt
index 0d5c3d50633..850157ee1bf 100644
--- a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ServerEngineUtilsNix.kt
+++ b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ServerEngineUtilsNix.kt
@@ -7,7 +7,7 @@ package io.ktor.server.engine
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual val WORKING_DIRECTORY_PATH: String get() = memScoped {
val result = allocArray(512)
getcwd(result, 512.convert())
diff --git a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ShutdownHookNative.kt b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ShutdownHookNative.kt
index 6f26f98f8b8..9f596dd5cf0 100644
--- a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ShutdownHookNative.kt
+++ b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/ShutdownHookNative.kt
@@ -6,7 +6,7 @@ package io.ktor.server.engine
import kotlinx.cinterop.*
import platform.posix.*
-import kotlin.concurrent.*
+import kotlin.native.concurrent.*
private val shutdownHook = AtomicReference {}
@@ -17,7 +17,7 @@ private val shutdownHook = AtomicReference {}
* is already stopped then there will be no hook and no [stop] function invocation possible.
* So [stop] block will be called once or never.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public actual fun ApplicationEngine.addShutdownHook(stop: () -> Unit) {
shutdownHook.value = stop
diff --git a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/internal/ApplicationUtilsNix.kt b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/internal/ApplicationUtilsNix.kt
index a03b050e230..ab9a56ca106 100644
--- a/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/internal/ApplicationUtilsNix.kt
+++ b/ktor-server/ktor-server-host-common/nix/src/io/ktor/server/engine/internal/ApplicationUtilsNix.kt
@@ -14,7 +14,6 @@ internal actual fun availableProcessorsBridge(): Int = 1
internal actual val Dispatchers.IOBridge: CoroutineDispatcher get() = Default
-@OptIn(ExperimentalForeignApi::class)
internal actual fun printError(message: Any?) {
fprintf(stderr, "%s", message?.toString())
}
diff --git a/ktor-server/ktor-server-plugins/ktor-server-auth/api/ktor-server-auth.api b/ktor-server/ktor-server-plugins/ktor-server-auth/api/ktor-server-auth.api
index 4fbbc3d19f7..ce44f63699d 100644
--- a/ktor-server/ktor-server-plugins/ktor-server-auth/api/ktor-server-auth.api
+++ b/ktor-server/ktor-server-plugins/ktor-server-auth/api/ktor-server-auth.api
@@ -108,7 +108,6 @@ public final class io/ktor/server/auth/AuthenticationStrategy : java/lang/Enum {
public static final field FirstSuccessful Lio/ktor/server/auth/AuthenticationStrategy;
public static final field Optional Lio/ktor/server/auth/AuthenticationStrategy;
public static final field Required Lio/ktor/server/auth/AuthenticationStrategy;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/server/auth/AuthenticationStrategy;
public static fun values ()[Lio/ktor/server/auth/AuthenticationStrategy;
}
@@ -487,7 +486,6 @@ public final class io/ktor/server/auth/OAuthServerSettings$OAuth2ServerSettings
public final class io/ktor/server/auth/OAuthVersion : java/lang/Enum {
public static final field V10a Lio/ktor/server/auth/OAuthVersion;
public static final field V20 Lio/ktor/server/auth/OAuthVersion;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/server/auth/OAuthVersion;
public static fun values ()[Lio/ktor/server/auth/OAuthVersion;
}
diff --git a/ktor-shared/ktor-websockets/api/ktor-websockets.api b/ktor-shared/ktor-websockets/api/ktor-websockets.api
index cee7c298f25..ba15482c588 100644
--- a/ktor-shared/ktor-websockets/api/ktor-websockets.api
+++ b/ktor-shared/ktor-websockets/api/ktor-websockets.api
@@ -29,7 +29,6 @@ public final class io/ktor/websocket/CloseReason$Codes : java/lang/Enum {
public static final field UNEXPECTED_CONDITION Lio/ktor/websocket/CloseReason$Codes;
public static final field VIOLATED_POLICY Lio/ktor/websocket/CloseReason$Codes;
public final fun getCode ()S
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/websocket/CloseReason$Codes;
public static fun values ()[Lio/ktor/websocket/CloseReason$Codes;
}
@@ -143,7 +142,6 @@ public final class io/ktor/websocket/FrameParser$State : java/lang/Enum {
public static final field HEADER0 Lio/ktor/websocket/FrameParser$State;
public static final field LENGTH Lio/ktor/websocket/FrameParser$State;
public static final field MASK_KEY Lio/ktor/websocket/FrameParser$State;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/websocket/FrameParser$State;
public static fun values ()[Lio/ktor/websocket/FrameParser$State;
}
@@ -164,7 +162,6 @@ public final class io/ktor/websocket/FrameType : java/lang/Enum {
public static final field PONG Lio/ktor/websocket/FrameType;
public static final field TEXT Lio/ktor/websocket/FrameType;
public final fun getControlFrame ()Z
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getOpcode ()I
public static fun valueOf (Ljava/lang/String;)Lio/ktor/websocket/FrameType;
public static fun values ()[Lio/ktor/websocket/FrameType;
diff --git a/ktor-utils/api/ktor-utils.api b/ktor-utils/api/ktor-utils.api
index e44955dc14f..e7bc2d93aae 100644
--- a/ktor-utils/api/ktor-utils.api
+++ b/ktor-utils/api/ktor-utils.api
@@ -235,7 +235,6 @@ public final class io/ktor/util/Platform : java/lang/Enum {
public static final field Jvm Lio/ktor/util/Platform;
public static final field Native Lio/ktor/util/Platform;
public static final field Node Lio/ktor/util/Platform;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/util/Platform;
public static fun values ()[Lio/ktor/util/Platform;
}
@@ -665,7 +664,6 @@ public final class io/ktor/util/date/Month : java/lang/Enum {
public static final field NOVEMBER Lio/ktor/util/date/Month;
public static final field OCTOBER Lio/ktor/util/date/Month;
public static final field SEPTEMBER Lio/ktor/util/date/Month;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getValue ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/util/date/Month;
public static fun values ()[Lio/ktor/util/date/Month;
@@ -685,7 +683,6 @@ public final class io/ktor/util/date/WeekDay : java/lang/Enum {
public static final field THURSDAY Lio/ktor/util/date/WeekDay;
public static final field TUESDAY Lio/ktor/util/date/WeekDay;
public static final field WEDNESDAY Lio/ktor/util/date/WeekDay;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public final fun getValue ()Ljava/lang/String;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/util/date/WeekDay;
public static fun values ()[Lio/ktor/util/date/WeekDay;
@@ -735,7 +732,6 @@ public final class io/ktor/util/debug/plugins/PluginTraceElement {
public final class io/ktor/util/debug/plugins/PluginTraceElement$PluginEvent : java/lang/Enum {
public static final field FINISHED Lio/ktor/util/debug/plugins/PluginTraceElement$PluginEvent;
public static final field STARTED Lio/ktor/util/debug/plugins/PluginTraceElement$PluginEvent;
- public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lio/ktor/util/debug/plugins/PluginTraceElement$PluginEvent;
public static fun values ()[Lio/ktor/util/debug/plugins/PluginTraceElement$PluginEvent;
}
diff --git a/ktor-utils/darwin/src/io/ktor/util/ThreadInfoDarwin.kt b/ktor-utils/darwin/src/io/ktor/util/ThreadInfoDarwin.kt
index f3f0e9b673a..a658176cb28 100644
--- a/ktor-utils/darwin/src/io/ktor/util/ThreadInfoDarwin.kt
+++ b/ktor-utils/darwin/src/io/ktor/util/ThreadInfoDarwin.kt
@@ -9,7 +9,6 @@ import platform.darwin.*
import platform.posix.*
import threadUtils.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun collectStack(thread: pthread_t): List {
val size = collect_stack(thread)
if (size < 0) throw IllegalArgumentException("Thread is stopped")
diff --git a/ktor-utils/linux/src/io/ktor/util/ThreadInfoLinux.kt b/ktor-utils/linux/src/io/ktor/util/ThreadInfoLinux.kt
index 616e0dec14b..91b97af16ad 100644
--- a/ktor-utils/linux/src/io/ktor/util/ThreadInfoLinux.kt
+++ b/ktor-utils/linux/src/io/ktor/util/ThreadInfoLinux.kt
@@ -9,7 +9,6 @@ import platform.linux.*
import platform.posix.*
import threadUtils.*
-@OptIn(ExperimentalForeignApi::class)
internal actual fun collectStack(thread: pthread_t): List {
val size = collect_stack(thread)
if (size < 0) throw IllegalArgumentException("Thread is stopped")
diff --git a/ktor-utils/mingwX64/src/io/ktor/util/CryptoMingw.kt b/ktor-utils/mingwX64/src/io/ktor/util/CryptoMingw.kt
index d69089086d0..371adbcf931 100644
--- a/ktor-utils/mingwX64/src/io/ktor/util/CryptoMingw.kt
+++ b/ktor-utils/mingwX64/src/io/ktor/util/CryptoMingw.kt
@@ -7,7 +7,7 @@ package io.ktor.util
import kotlinx.cinterop.*
import platform.windows.*
-@OptIn(ExperimentalUnsignedTypes::class, ExperimentalForeignApi::class)
+@OptIn(ExperimentalUnsignedTypes::class)
internal actual fun secureRandom(bytes: ByteArray) {
bytes.toUByteArray().usePinned { pinned ->
val result = BCryptGenRandom(
diff --git a/ktor-utils/mingwX64/src/io/ktor/util/date/DateMingw.kt b/ktor-utils/mingwX64/src/io/ktor/util/date/DateMingw.kt
index b8df3367a4d..9e32671321a 100644
--- a/ktor-utils/mingwX64/src/io/ktor/util/date/DateMingw.kt
+++ b/ktor-utils/mingwX64/src/io/ktor/util/date/DateMingw.kt
@@ -8,7 +8,6 @@ import kotlinx.cinterop.*
import platform.posix.*
import platform.windows.*
-@OptIn(ExperimentalForeignApi::class)
@Suppress("FunctionName")
internal actual fun system_time(tm: CValuesRef?): Long {
return _mkgmtime(tm).convert()
@@ -18,7 +17,7 @@ internal actual fun system_time(tm: CValuesRef?): Long {
* Gets current system time in milliseconds since a certain moment in the past,
* only delta between two subsequent calls makes sense.
*/
-@OptIn(ExperimentalForeignApi::class)
+
public actual fun getTimeMillis(): Long = memScoped {
val timeHolder = alloc()
GetSystemTimeAsFileTime(timeHolder.ptr)
diff --git a/ktor-utils/nix/src/io/ktor/util/CryptoPosix.kt b/ktor-utils/nix/src/io/ktor/util/CryptoPosix.kt
index b48538c2ea9..e6bfd02e6bb 100644
--- a/ktor-utils/nix/src/io/ktor/util/CryptoPosix.kt
+++ b/ktor-utils/nix/src/io/ktor/util/CryptoPosix.kt
@@ -7,7 +7,7 @@ package io.ktor.util
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(ExperimentalUnsignedTypes::class, UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(ExperimentalUnsignedTypes::class, UnsafeNumber::class)
internal actual fun secureRandom(bytes: ByteArray) {
val fd = fopen("/dev/urandom", "rb") ?: return
val size = bytes.size
diff --git a/ktor-utils/nix/src/io/ktor/util/date/DateNix.kt b/ktor-utils/nix/src/io/ktor/util/date/DateNix.kt
index f1d9766f4a4..944cb38538e 100644
--- a/ktor-utils/nix/src/io/ktor/util/date/DateNix.kt
+++ b/ktor-utils/nix/src/io/ktor/util/date/DateNix.kt
@@ -8,14 +8,14 @@ import kotlinx.cinterop.*
import platform.posix.*
@Suppress("FunctionName")
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
internal actual fun system_time(tm: CValuesRef?): Long = timegm(tm).convert()
/**
* Gets current system time in milliseconds since a certain moment in the past,
* only delta between two subsequent calls makes sense.
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun getTimeMillis(): Long = memScoped {
val timeHolder = alloc()
clock_gettime(CLOCK_REALTIME.convert(), timeHolder.ptr)
diff --git a/ktor-utils/posix/src/io/ktor/util/CoroutineUtils.kt b/ktor-utils/posix/src/io/ktor/util/CoroutineUtils.kt
index 889bb2a4eda..849492b12b7 100644
--- a/ktor-utils/posix/src/io/ktor/util/CoroutineUtils.kt
+++ b/ktor-utils/posix/src/io/ktor/util/CoroutineUtils.kt
@@ -14,20 +14,17 @@ import kotlin.native.concurrent.*
public fun Dispatchers.createFixedThreadDispatcher(name: String, threads: Int): CloseableCoroutineDispatcher =
MultiWorkerDispatcher(name, threads)
-@OptIn(ObsoleteWorkersApi::class)
private val CLOSE_WORKER: Worker by lazy {
Worker.start(name = "CLOSE_WORKER")
}
-@OptIn(InternalAPI::class, ObsoleteWorkersApi::class)
+@OptIn(InternalAPI::class)
private class MultiWorkerDispatcher(name: String, workersCount: Int) : CloseableCoroutineDispatcher() {
private val closed = atomic(false)
private val tasksQueue = Channel(Channel.UNLIMITED)
- @OptIn(ObsoleteWorkersApi::class)
private val workers = Array(workersCount) { Worker.start(name = "$name-$it") }
- @OptIn(ObsoleteWorkersApi::class)
private val futures = mutableListOf>()
init {
diff --git a/ktor-utils/posix/src/io/ktor/util/ThreadInfo.kt b/ktor-utils/posix/src/io/ktor/util/ThreadInfo.kt
index 16a4a75a871..7bef189876a 100644
--- a/ktor-utils/posix/src/io/ktor/util/ThreadInfo.kt
+++ b/ktor-utils/posix/src/io/ktor/util/ThreadInfo.kt
@@ -16,7 +16,6 @@ import kotlin.native.concurrent.*
private val init = setSignalHandler()
@InternalAPI
-@OptIn(ObsoleteWorkersApi::class, ExperimentalForeignApi::class)
public object ThreadInfo {
private val threads = ConcurrentMap(initialCapacity = 32)
@@ -24,19 +23,16 @@ public object ThreadInfo {
init
}
- @OptIn(ObsoleteWorkersApi::class, ExperimentalForeignApi::class)
public fun registerCurrentThread() {
@Suppress("UNNECESSARY_NOT_NULL_ASSERTION")
val thread = pthread_self()!!
threads[Worker.current] = thread
}
- @OptIn(ObsoleteWorkersApi::class)
public fun dropWorker(worker: Worker) {
threads.remove(worker)
}
- @OptIn(ExperimentalNativeApi::class, ObsoleteWorkersApi::class)
public fun getAllStackTraces(): List {
if (kotlin.native.Platform.osFamily == OsFamily.WINDOWS) return emptyList()
@@ -68,7 +64,6 @@ public object ThreadInfo {
}
}
- @OptIn(ObsoleteWorkersApi::class)
public fun stopAllWorkers() {
for (worker in threads.keys) {
if (worker == Worker.current) continue
@@ -86,7 +81,6 @@ public class WorkerStacktrace(
public val stacktrace: List
)
-@OptIn(kotlinx.cinterop.ExperimentalForeignApi::class)
internal expect fun collectStack(thread: pthread_t): List
internal expect fun setSignalHandler()
diff --git a/ktor-utils/posix/src/io/ktor/util/date/DateNative.kt b/ktor-utils/posix/src/io/ktor/util/date/DateNative.kt
index 7276a4e5701..3a894016de3 100644
--- a/ktor-utils/posix/src/io/ktor/util/date/DateNative.kt
+++ b/ktor-utils/posix/src/io/ktor/util/date/DateNative.kt
@@ -11,7 +11,7 @@ import platform.posix.*
* Create new gmt date from the [timestamp].
* @param timestamp is a number of epoch milliseconds (it is `now` by default).
*/
-@OptIn(UnsafeNumber::class, ExperimentalForeignApi::class)
+@OptIn(UnsafeNumber::class)
public actual fun GMTDate(timestamp: Long?): GMTDate = memScoped {
val timeHolder = alloc()
val current: Long = if (timestamp == null) {
@@ -48,7 +48,7 @@ public actual fun GMTDate(timestamp: Long?): GMTDate = memScoped {
/**
* Create an instance of [GMTDate] from the specified date/time components
*/
-@OptIn(ExperimentalForeignApi::class)
+
public actual fun GMTDate(
seconds: Int,
minutes: Int,
@@ -77,6 +77,5 @@ public actual fun GMTDate(
return GMTDate(timestamp * 1000L)
}
-@OptIn(ExperimentalForeignApi::class)
@Suppress("FunctionName")
internal expect fun system_time(tm: CValuesRef?): Long
diff --git a/ktor-utils/posix/src/io/ktor/util/logging/KtorSimpleLoggerNative.kt b/ktor-utils/posix/src/io/ktor/util/logging/KtorSimpleLoggerNative.kt
index 09d469fc741..67a997cdcdf 100644
--- a/ktor-utils/posix/src/io/ktor/util/logging/KtorSimpleLoggerNative.kt
+++ b/ktor-utils/posix/src/io/ktor/util/logging/KtorSimpleLoggerNative.kt
@@ -9,7 +9,6 @@ import platform.posix.*
private val KTOR_LOG_LEVEL_KEY = "KTOR_LOG_LEVEL"
-@OptIn(ExperimentalForeignApi::class)
@Suppress("FunctionName")
public actual fun KtorSimpleLogger(
name: String
@@ -17,7 +16,7 @@ public actual fun KtorSimpleLogger(
override val level: LogLevel = getenv(KTOR_LOG_LEVEL_KEY)?.let { rawLevel ->
val level = rawLevel.toKString()
- LogLevel.entries.firstOrNull { it.name == level }
+ LogLevel.values().firstOrNull { it.name == level }
} ?: LogLevel.INFO
private fun log(level: LogLevel, message: String) {
diff --git a/ktor-utils/posix/src/io/ktor/util/pipeline/PipelineContext.posix.kt b/ktor-utils/posix/src/io/ktor/util/pipeline/PipelineContext.posix.kt
index 26f0c165652..2fca05275c0 100644
--- a/ktor-utils/posix/src/io/ktor/util/pipeline/PipelineContext.posix.kt
+++ b/ktor-utils/posix/src/io/ktor/util/pipeline/PipelineContext.posix.kt
@@ -7,5 +7,4 @@ package io.ktor.util.pipeline
import kotlinx.cinterop.*
import platform.posix.*
-@OptIn(ExperimentalForeignApi::class)
internal actual val DISABLE_SFG: Boolean = getenv("KTOR_INTERNAL_DISABLE_SFG")?.toKString() == "true"