[K/N] Mark UnhandledExceptionHook-related API as experimental
As a part of efforts to stabilize Native stdlib.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
|
||||
import kotlin.native.concurrent.freeze
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*/
|
||||
|
||||
// FILE: hello.kt
|
||||
@file:OptIn(FreezingIsDeprecated::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::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)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::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)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::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)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::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)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
@file:OptIn(FreezingIsDeprecated::class)
|
||||
@file:OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
|
||||
import kotlin.native.concurrent.*
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@ public class IncorrectDereferenceException : RuntimeException {
|
||||
/**
|
||||
* Typealias describing custom exception reporting hook.
|
||||
*/
|
||||
@ExperimentalStdlibApi
|
||||
public typealias ReportUnhandledExceptionHook = Function1<Throwable, Unit>
|
||||
|
||||
/**
|
||||
@@ -55,6 +56,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
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook?): ReportUnhandledExceptionHook? {
|
||||
try {
|
||||
@@ -66,7 +68,7 @@ public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook?): Repor
|
||||
|
||||
@Suppress("CONFLICTING_OVERLOADS")
|
||||
@Deprecated("Provided for binary compatibility", level = DeprecationLevel.HIDDEN)
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
public fun setUnhandledExceptionHook(hook: ReportUnhandledExceptionHook): ReportUnhandledExceptionHook? {
|
||||
try {
|
||||
return UnhandledExceptionHookHolder.hook.swap(hook)
|
||||
|
||||
@@ -144,7 +144,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)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
internal object UnhandledExceptionHookHolder {
|
||||
internal val hook: FreezableAtomicReference<ReportUnhandledExceptionHook?> =
|
||||
if (Platform.memoryModel == MemoryModel.EXPERIMENTAL) {
|
||||
@@ -157,7 +157,7 @@ internal object UnhandledExceptionHookHolder {
|
||||
// TODO: Can be removed only when native-mt coroutines stop using it.
|
||||
@PublishedApi
|
||||
@ExportForCppRuntime
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
internal fun OnUnhandledException(throwable: Throwable) {
|
||||
val handler = UnhandledExceptionHookHolder.hook.value
|
||||
if (handler == null) {
|
||||
@@ -172,7 +172,7 @@ internal fun OnUnhandledException(throwable: Throwable) {
|
||||
}
|
||||
|
||||
@ExportForCppRuntime("Kotlin_runUnhandledExceptionHook")
|
||||
@OptIn(FreezingIsDeprecated::class)
|
||||
@OptIn(FreezingIsDeprecated::class, ExperimentalStdlibApi::class)
|
||||
internal fun runUnhandledExceptionHook(throwable: Throwable) {
|
||||
val handler = UnhandledExceptionHookHolder.hook.value ?: throw throwable
|
||||
handler(throwable)
|
||||
|
||||
Reference in New Issue
Block a user