From 95b3858e8eba5214333bdabd50fb4df4aa1ad734 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Wed, 24 Aug 2022 13:17:13 +0200 Subject: [PATCH] fix: handle isValue exceptions --- .../src/main/kotlin/io/mockk/ValueClassSupportAndroid.kt | 3 +++ .../src/jvmMain/kotlin/io/mockk/ValueClassSupport.kt | 3 +++ 2 files changed, 6 insertions(+) diff --git a/modules/mockk-agent-android/src/main/kotlin/io/mockk/ValueClassSupportAndroid.kt b/modules/mockk-agent-android/src/main/kotlin/io/mockk/ValueClassSupportAndroid.kt index 5f6ca43c4..b139cd1b6 100644 --- a/modules/mockk-agent-android/src/main/kotlin/io/mockk/ValueClassSupportAndroid.kt +++ b/modules/mockk-agent-android/src/main/kotlin/io/mockk/ValueClassSupportAndroid.kt @@ -3,6 +3,7 @@ package io.mockk import kotlin.reflect.KClass import kotlin.reflect.KProperty1 import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.jvm.internal.KotlinReflectionInternalError import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField @@ -62,4 +63,6 @@ private val KClass.isValue_safe: Boolean this.isValue } catch (_: UnsupportedOperationException) { false + } catch (_: KotlinReflectionInternalError) { + false } diff --git a/modules/mockk-agent/src/jvmMain/kotlin/io/mockk/ValueClassSupport.kt b/modules/mockk-agent/src/jvmMain/kotlin/io/mockk/ValueClassSupport.kt index 5f6ca43c4..b139cd1b6 100644 --- a/modules/mockk-agent/src/jvmMain/kotlin/io/mockk/ValueClassSupport.kt +++ b/modules/mockk-agent/src/jvmMain/kotlin/io/mockk/ValueClassSupport.kt @@ -3,6 +3,7 @@ package io.mockk import kotlin.reflect.KClass import kotlin.reflect.KProperty1 import kotlin.reflect.full.declaredMemberProperties +import kotlin.reflect.jvm.internal.KotlinReflectionInternalError import kotlin.reflect.jvm.isAccessible import kotlin.reflect.jvm.javaField @@ -62,4 +63,6 @@ private val KClass.isValue_safe: Boolean this.isValue } catch (_: UnsupportedOperationException) { false + } catch (_: KotlinReflectionInternalError) { + false }