From 37e4ee5bc6dfd64bb46e9e81367eb6b84e0116c5 Mon Sep 17 00:00:00 2001 From: Him188 Date: Sun, 12 Jan 2020 00:40:06 +0800 Subject: [PATCH] Fix build --- .../kotlin/net/mamoe/mirai/utils/cryptor/contentToString.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/cryptor/contentToString.kt b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/cryptor/contentToString.kt index 82053ee25..117f0cf53 100644 --- a/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/cryptor/contentToString.kt +++ b/mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/utils/cryptor/contentToString.kt @@ -4,6 +4,8 @@ import java.lang.reflect.Field import kotlin.reflect.full.allSuperclasses +val FIELD_TRY_SET_ACCESSIBLE = Field::class.java.declaredMethods.firstOrNull { it.name == "trySetAccessible" } + actual fun Any.contentToStringReflectively(prefix: String): String { val newPrefix = prefix + ProtoMap.indent return (this::class.simpleName ?: "") + "#" + this::class.hashCode() + " {\n" + @@ -13,7 +15,7 @@ actual fun Any.contentToStringReflectively(prefix: String): String { .joinToStringPrefixed( prefix = newPrefix ) { - it.trySetAccessible() + FIELD_TRY_SET_ACCESSIBLE?.invoke(it, true) ?: kotlin.run { it.isAccessible = true } it.name + "=" + kotlin.runCatching { val value = it.get(this) if (value == this) ""