From 47b3859641cdef6f157cf45406a2a2fd271d0c8f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Wed, 18 Nov 2015 04:29:45 +0300 Subject: [PATCH] Deprecate monitorEnter and monitorExit not to be used from user code. --- libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt | 2 ++ libraries/stdlib/src/kotlin/util/Synchronized.kt | 1 + 2 files changed, 3 insertions(+) diff --git a/libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt b/libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt index 55b19030c38..32b5c2ea9f2 100644 --- a/libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt +++ b/libraries/stdlib/src/kotlin/jvm/internal/unsafe/monitor.kt @@ -20,8 +20,10 @@ import kotlin.jvm.internal.Intrinsic /** @suppress */ @Intrinsic("kotlin.jvm.internal.unsafe.monitorEnter") +@Deprecated("This function supports the standard library infrastructure and is not intended to be used directly from user code.") public fun monitorEnter(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately") /** @suppress */ @Intrinsic("kotlin.jvm.internal.unsafe.monitorExit") +@Deprecated("This function supports the standard library infrastructure and is not intended to be used directly from user code.") public fun monitorExit(monitor: Any): Unit = throw UnsupportedOperationException("This function can only be used privately") diff --git a/libraries/stdlib/src/kotlin/util/Synchronized.kt b/libraries/stdlib/src/kotlin/util/Synchronized.kt index 4457dc11ddc..fbbca4192fe 100644 --- a/libraries/stdlib/src/kotlin/util/Synchronized.kt +++ b/libraries/stdlib/src/kotlin/util/Synchronized.kt @@ -8,6 +8,7 @@ import kotlin.jvm.internal.unsafe.* /** * Executes the given function [block] while holding the monitor of the given object [lock]. */ +@Suppress("DEPRECATION") public inline fun synchronized(lock: Any, block: () -> R): R { monitorEnter(lock) try {