From 82de485b17da042931521e13473b4d2b7052e3eb Mon Sep 17 00:00:00 2001 From: Username404 Date: Mon, 17 May 2021 14:44:44 +0200 Subject: [PATCH] Don't obfuscate static fields in fr.username404.gui.feature to fix reflection on objects --- build.gradle.kts | 2 +- .../kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 7d0377c..424b641 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -45,7 +45,7 @@ subprojects { keep("class $group.snowygui.fabric.**") keep("class $group.snowygui.forge.**") keepnames("class $group.snowygui.Snowy") - keep("class $group.snowygui.gui.feature.**") + keep("class $group.snowygui.gui.feature.** { static ; }") keepclassmembers("class $group.snowygui.** { public protected ; }") keepattributes("*Annotation*, Signature, InnerClasses, EnclosingMethod, MethodParameters, Synthetic, Exceptions") obfuscationdictionary("$dictionariesDir/dictionary.txt") diff --git a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt index 7dc753c..dc9ca7a 100644 --- a/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt +++ b/common/src/main/kotlin/fr/username404/snowygui/gui/feature/ButtonImpl.kt @@ -11,7 +11,6 @@ import fr.username404.snowygui.gui.Renderable.Rendering.defaultRectFunc import fr.username404.snowygui.gui.elements.ClickBox import fr.username404.snowygui.gui.feature.ButtonInfo.Companion.Type import kotlin.reflect.full.findAnnotation -import kotlin.reflect.jvm.isAccessible sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { companion object { @@ -22,9 +21,7 @@ sealed class ButtonImpl: ColoredElement(0.0, 0.0, 73, 8, opacity = 0.60F) { ((try { it.getConstructor().newInstance() } catch (e: NoSuchMethodException) { - try { - it.kotlin.objectInstance!! - } catch (e: NullPointerException) { it.kotlin.constructors.first().also { build -> build.isAccessible = true }.call() } + it.kotlin.objectInstance!! }) as ButtonImpl).let { impl -> with(impl) { if (info.kind == ButtonInfo.Companion.Type.TOGGLE) {