diff --git a/backend/mirai-console/src/internal/util/CommonUtils.kt b/backend/mirai-console/src/internal/util/CommonUtils.kt index 037bd0bb7..b1c2c2848 100644 --- a/backend/mirai-console/src/internal/util/CommonUtils.kt +++ b/backend/mirai-console/src/internal/util/CommonUtils.kt @@ -11,6 +11,8 @@ package net.mamoe.mirai.console.internal.util +import net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl + internal inline fun runIgnoreException(block: () -> R): R? { try { return block() @@ -41,6 +43,7 @@ internal fun getCallerClassloader(): ClassLoader? { net.mamoe.mirai.console.TestMiraiConosleKt.main(TestMiraiConosle.kt) */ val traces = Thread.currentThread().stackTrace - Class.forName(traces[3].className).classLoader + val classname = traces[3].className + BuiltInJvmPluginLoaderImpl.classLoaders.firstOrNull { it.findClass(classname, true) != null } }.getOrNull() } \ No newline at end of file diff --git a/backend/mirai-console/src/plugin/jvm/JvmPluginDescription.kt b/backend/mirai-console/src/plugin/jvm/JvmPluginDescription.kt index 6a4452879..28d9a96a8 100644 --- a/backend/mirai-console/src/plugin/jvm/JvmPluginDescription.kt +++ b/backend/mirai-console/src/plugin/jvm/JvmPluginDescription.kt @@ -67,7 +67,7 @@ public interface JvmPluginDescription : PluginDescription { * @param filename [ClassLoader.getResourceAsStream] 的参数 `name` * @param pluginClassloader 默认通过 [Thread.getStackTrace] 获取调用方 [Class] 然后获取其 [Class.getClassLoader]. */ - @JvmOverloads + // @JvmOverloads // compiler error @JvmStatic public fun loadFromResource( filename: String = "plugin.yml",