Commit 37e4ee5b authored by Him188's avatar Him188

Fix build

parent 186fa5d8
...@@ -4,6 +4,8 @@ import java.lang.reflect.Field ...@@ -4,6 +4,8 @@ import java.lang.reflect.Field
import kotlin.reflect.full.allSuperclasses 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 { actual fun Any.contentToStringReflectively(prefix: String): String {
val newPrefix = prefix + ProtoMap.indent val newPrefix = prefix + ProtoMap.indent
return (this::class.simpleName ?: "<UnnamedClass>") + "#" + this::class.hashCode() + " {\n" + return (this::class.simpleName ?: "<UnnamedClass>") + "#" + this::class.hashCode() + " {\n" +
...@@ -13,7 +15,7 @@ actual fun Any.contentToStringReflectively(prefix: String): String { ...@@ -13,7 +15,7 @@ actual fun Any.contentToStringReflectively(prefix: String): String {
.joinToStringPrefixed( .joinToStringPrefixed(
prefix = newPrefix prefix = newPrefix
) { ) {
it.trySetAccessible() FIELD_TRY_SET_ACCESSIBLE?.invoke(it, true) ?: kotlin.run { it.isAccessible = true }
it.name + "=" + kotlin.runCatching { it.name + "=" + kotlin.runCatching {
val value = it.get(this) val value = it.get(this)
if (value == this) "<this>" if (value == this) "<this>"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment