[K/N] Mark UnhandledExceptionHook-related API with ExperimentalNativeApi
Instead of ExperimentalStdlibApi As a part of efforts to stabilize Native stdlib #KT-55765.
This commit is contained in:
committed by
Space Team
parent
da0cc2ea4d
commit
5407ac1c72
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.native.concurrent.freeze
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
// FILE: hello.kt
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
import kotlin.native.internal.*
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, kotlin.native.runtime.NativeRuntimeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2010-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the LICENSE file.
|
||||
*/
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class, ObsoleteWorkersApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, ObsoleteWorkersApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class, ObsoleteWorkersApi::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, kotlin.experimental.ExperimentalNativeApi::class, ObsoleteWorkersApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class IncorrectDereferenceException : RuntimeException {
|
||||
/**
|
||||
* Typealias describing custom exception reporting hook.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalNativeApi
|
||||
public typealias ReportUnhandledExceptionHook = Function1<Throwable, Unit>
|
||||
|
||||
/**
|
||||
@@ -57,7 +57,7 @@ public typealias ReportUnhandledExceptionHook = Function1<Throwable, Unit>
|
||||
* Set or default hook is also invoked by [processUnhandledException].
|
||||
* With the legacy MM the hook must be a frozen lambda so that it could be called from any thread/worker.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalNativeApi
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook?): ReportUnhandledExceptionHook? {
|
||||
try {
|
||||
@@ -69,7 +69,7 @@ public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook?): Repor
|
||||
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook): ReportUnhandledExceptionHook? {
|
||||
try {
|
||||
return UnhandledExceptionHookHolder.hook.swap(hook)
|
||||
@@ -81,7 +81,7 @@ public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook): Report
|
||||
/**
|
||||
* Returns a user-defined unhandled exception hook set by [setUnhandledExceptionHook] or `null` if no user-defined hooks were set.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalNativeApi
|
||||
@SinceKotlin("1.6")
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
public fun getUnhandledExceptionHook(): ReportUnhandledExceptionHook? {
|
||||
@@ -95,7 +95,7 @@ public fun getUnhandledExceptionHook(): ReportUnhandledExceptionHook? {
|
||||
* If the hook is not present, calls [terminateWithUnhandledException] with [throwable].
|
||||
* If the hook fails with exception, calls [terminateWithUnhandledException] with exception from the hook.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalNativeApi
|
||||
@SinceKotlin("1.6")
|
||||
@GCUnsafeCall("Kotlin_processUnhandledException")
|
||||
public external fun processUnhandledException(throwable: Throwable): Unit
|
||||
@@ -106,7 +106,7 @@ public external fun processUnhandledException(throwable: Throwable): Unit
|
||||
*
|
||||
* `terminateWithUnhandledException` can be used to emulate an abrupt termination of the application with an uncaught exception.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
@ExperimentalNativeApi
|
||||
@SinceKotlin("1.6")
|
||||
@GCUnsafeCall("Kotlin_terminateWithUnhandledException")
|
||||
public external fun terminateWithUnhandledException(throwable: Throwable): Nothing
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.internal
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.coroutines.*
|
||||
import kotlin.coroutines.intrinsics.*
|
||||
import kotlin.coroutines.native.internal.*
|
||||
@@ -29,7 +30,7 @@ private object EmptyCompletion : Continuation<Any?> {
|
||||
override val context: CoroutineContext
|
||||
get() = EmptyCoroutineContext
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
@OptIn(ExperimentalNativeApi::class)
|
||||
override fun resumeWith(result: Result<Any?>) {
|
||||
val exception = result.exceptionOrNull() ?: return
|
||||
processUnhandledException(exception)
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
package kotlin.native.internal
|
||||
|
||||
import kotlin.experimental.ExperimentalNativeApi
|
||||
import kotlin.internal.getProgressionLastElement
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.native.concurrent.FreezableAtomicReference
|
||||
@@ -152,7 +153,7 @@ internal fun ReportUnhandledException(throwable: Throwable) {
|
||||
// Using object to make sure that `hook` is initialized when it's needed instead of
|
||||
// in a normal global initialization flow. This is important if some global happens
|
||||
// to throw an exception during it's initialization before this hook would've been initialized.
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
internal object UnhandledExceptionHookHolder {
|
||||
internal val hook: FreezableAtomicReference<ReportUnhandledExceptionHook?> =
|
||||
if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) {
|
||||
@@ -165,7 +166,7 @@ internal object UnhandledExceptionHookHolder {
|
||||
// TODO: Can be removed only when native-mt coroutines stop using it.
|
||||
@PublishedApi
|
||||
@ExportForCppRuntime
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
internal fun OnUnhandledException(throwable: Throwable) {
|
||||
val handler = UnhandledExceptionHookHolder.hook.value
|
||||
if (handler == null) {
|
||||
@@ -180,7 +181,7 @@ internal fun OnUnhandledException(throwable: Throwable) {
|
||||
}
|
||||
|
||||
@ExportForCppRuntime("Kotlin_runUnhandledExceptionHook")
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalNativeApi::class)
|
||||
internal fun runUnhandledExceptionHook(throwable: Throwable) {
|
||||
val handler = UnhandledExceptionHookHolder.hook.value ?: throw throwable
|
||||
handler(throwable)
|
||||
|
||||
Reference in New Issue
Block a user