From b9b2b51c3dfba22be4e5798677efbd615d61f6fa 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 01:27:10 +0800 Subject: [PATCH] fix java.lang.NoSuchMethodError fix java.lang.NoSuchMethodError: No virtual method getDeclaredAnnotation(Ljava/lang/Class;)L --- .../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 ad27e484d7..9e2960aa2c 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