diff --git a/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/PluginDependOnOther.kt b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/PluginDependOnOther.kt index dac898e09..6b4dcdb22 100644 --- a/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/PluginDependOnOther.kt +++ b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/PluginDependOnOther.kt @@ -13,7 +13,6 @@ import net.mamoe.console.integrationtest.ep.mcitselftest.MCITSelfTestPlugin import net.mamoe.mirai.console.plugin.jvm.JvmPluginDescription import net.mamoe.mirai.console.plugin.jvm.KotlinPlugin import net.mamoe.mirai.utils.info -import kotlin.test.assertFails import kotlin.test.assertFailsWith import kotlin.test.assertNotEquals import kotlin.test.assertSame @@ -52,5 +51,10 @@ public object PluginDependOnOther : KotlinPlugin( Class.forName("net.mamoe.assertion.something.not.existing") } } + + // region https://github.com/mamoe/mirai/issues/1920 + Class.forName("net.mamoe.console.integrationtest.ep.pddd.p2.PDOO_OtherClass") + Class.forName("net.mamoe.console.integrationtest.ep.pddd.PDOO_OtherClass") + // endregion } } diff --git a/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass1.kt b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass1.kt new file mode 100644 index 000000000..b5e97d8c1 --- /dev/null +++ b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass1.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2019-2022 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/dev/LICENSE + */ + +@file:Suppress("unused", "PackageDirectoryMismatch", "ClassName") + +package net.mamoe.console.integrationtest.ep.pddd + +// https://github.com/mamoe/mirai/issues/1920 +@PublishedApi +internal class PDOO_OtherClass { + companion object { + init { + Thread.dumpStack() + println("OC Loaded") + } + } +} diff --git a/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass2.kt b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass2.kt new file mode 100644 index 000000000..bcdb60e3a --- /dev/null +++ b/mirai-console/backend/integration-test/testers/plugin-depend-on-other/src/issue1920/OtherClass2.kt @@ -0,0 +1,23 @@ +/* + * Copyright 2019-2022 Mamoe Technologies and contributors. + * + * 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证. + * Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link. + * + * https://github.com/mamoe/mirai/blob/dev/LICENSE + */ + +@file:Suppress("unused", "PackageDirectoryMismatch", "ClassName") + +package net.mamoe.console.integrationtest.ep.pddd.p2 + +// https://github.com/mamoe/mirai/issues/1920 +@PublishedApi +internal class PDOO_OtherClass { + companion object { + init { + Thread.dumpStack() + println("OC Loaded") + } + } +} diff --git a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginClassLoader.kt b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginClassLoader.kt index 7a6d7a022..16d7749ef 100644 --- a/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginClassLoader.kt +++ b/mirai-console/backend/mirai-console/src/internal/plugin/JvmPluginClassLoader.kt @@ -206,7 +206,9 @@ internal class JvmPluginClassLoaderN : URLClassLoader { if (declaredFilter?.isExported(name) == false) return null synchronized(getClassLoadingLock(name)) { findLoadedClass(name)?.let { return it } - return super.findClass(name) + try { + return super.findClass(name) + } catch (ignored: ClassNotFoundException) {} } } return null