From 0e4d5efd38bf77f6ebc2d67f365435d17d02a86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E6=80=A1=E7=84=B6?= <63996691+zhaodice@users.noreply.github.com> Date: Sat, 19 Nov 2022 07:26:52 +0800 Subject: [PATCH] =?UTF-8?q?[console]=20=E4=BF=AE=E5=A4=8D=20JvmPluginInter?= =?UTF-8?q?nal=20=E5=9C=A8=20Android=20=20java.lang.NoSuchMethodError=20(#?= =?UTF-8?q?2354)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix java.lang.NoSuchMethodError fix java.lang.NoSuchMethodError: No virtual method getDeclaredAnnotation(Ljava/lang/Class;)L * fix formatting Co-authored-by: Him188 --- .../src/internal/plugin/JvmPluginInternal.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt index ad27e484d..cf5088c59 100644 --- a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt +++ b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginInternal.kt @@ -126,7 +126,12 @@ internal abstract class JvmPluginInternal( parentPermission if (!firstRun) refreshCoroutineContext() - val except = javaClass.getDeclaredAnnotation(ConsoleJvmPluginFuncCallbackStatusExcept.OnEnable::class.java) + val except = try { + javaClass.getDeclaredAnnotation(ConsoleJvmPluginFuncCallbackStatusExcept.OnEnable::class.java) + } catch (e: Throwable) { + null + } + kotlin.runCatching { onEnable() }.fold( @@ -244,4 +249,4 @@ internal inline fun AtomicLong.updateWhen(condition: (Long) -> Boolean, update: } } -internal val Throwable.rootCauseOrSelf: Throwable get() = generateSequence(this) { it.cause }.lastOrNull() ?: this \ No newline at end of file +internal val Throwable.rootCauseOrSelf: Throwable get() = generateSequence(this) { it.cause }.lastOrNull() ?: this