|
10 | 10 |
|
11 | 11 | package net.mamoe.mirai.console.internal.plugin
|
12 | 12 |
|
| 13 | +import net.mamoe.mirai.console.MiraiConsole |
13 | 14 | import net.mamoe.mirai.console.plugin.jvm.ExportManager
|
14 |
| -import net.mamoe.mirai.utils.MiraiLogger |
15 |
| -import net.mamoe.mirai.utils.debug |
16 |
| -import net.mamoe.mirai.utils.verbose |
| 15 | +import net.mamoe.mirai.utils.* |
17 | 16 | import org.eclipse.aether.artifact.Artifact
|
18 | 17 | import org.eclipse.aether.graph.DependencyFilter
|
19 | 18 | import java.io.File
|
@@ -94,6 +93,12 @@ internal class JvmPluginClassLoaderN : URLClassLoader {
|
94 | 93 | lateinit var pluginSharedCL: DynLibClassLoader
|
95 | 94 | lateinit var pluginIndependentCL: DynLibClassLoader
|
96 | 95 |
|
| 96 | + @Suppress("PrivatePropertyName") |
| 97 | + private val file_: File |
| 98 | + get() = file |
| 99 | + |
| 100 | + var linkedLogger by lateinitMutableProperty { MiraiConsole.createLogger("JvmPlugin[" + file_.name + "]") } |
| 101 | + val undefinedDependencies = mutableSetOf<String>() |
97 | 102 |
|
98 | 103 | private constructor(file: File, ctx: JvmPluginsLoadingCtx, unused: Unit) : super(
|
99 | 104 | arrayOf(), ctx.sharedLibrariesLoader
|
@@ -241,7 +246,13 @@ internal class JvmPluginClassLoaderN : URLClassLoader {
|
241 | 246 | // Finally, try search from other plugins and console system
|
242 | 247 | ctx.pluginClassLoaders.forEach { other ->
|
243 | 248 | if (other !== this && other !in dependencies) {
|
244 |
| - other.resolvePluginPublicClass(name)?.let { return it } |
| 249 | + other.resolvePluginPublicClass(name)?.let { |
| 250 | + if (undefinedDependencies.add(other.file.name)) { |
| 251 | + linkedLogger.warning { "Linked class $name in ${other.file.name} but plugin not depend on it." } |
| 252 | + linkedLogger.warning { "Class loading logic may change in feature." } |
| 253 | + } |
| 254 | + return it |
| 255 | + } |
245 | 256 | }
|
246 | 257 | }
|
247 | 258 | return AllDependenciesClassesHolder.appClassLoader.loadClass(name)
|
|
0 commit comments