change file name 'PluginsClassLoader.kt' ot 'PluginsLoader.kt'

fix class init issues and fix reload exception
This commit is contained in:
Sincky 2020-04-08 15:59:05 +08:00
parent 5a599e0141
commit 8ffae709ea
2 changed files with 4 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import net.mamoe.mirai.console.command.Command
import net.mamoe.mirai.console.command.CommandManager
import net.mamoe.mirai.console.command.CommandSender
import net.mamoe.mirai.console.encodeToString
import net.mamoe.mirai.utils.LockFreeLinkedList
import net.mamoe.mirai.utils.SimpleLogger
import java.io.File
import java.io.InputStream
@ -58,7 +59,7 @@ object PluginManager {
* 他的优先级取决于依赖,
* 在这个队列中, 被依赖的插件会在依赖的插件之前
*/
private val pluginsSequence: MutableList<PluginBase> = mutableListOf()
private val pluginsSequence: LockFreeLinkedList<PluginBase> = LockFreeLinkedList()
/**
@ -230,7 +231,7 @@ object PluginManager {
nameToPluginBaseMap[description.name] = plugin
pluginDescriptions[description.name] = description
plugin.pluginName = description.name
pluginsSequence.add(plugin)//按照实际加载顺序加入队列
pluginsSequence.addLast(plugin)//按照实际加载顺序加入队列
return true
}

View File

@ -48,7 +48,7 @@ internal class PluginsLoader(private val parentClassLoader: ClassLoader) {
if(!pluginLoaders.containsKey(pluginName)){
pluginLoaders[pluginName] = PluginClassLoader(pluginName,jarFile, this, parentClassLoader)
}
return Class.forName(mainClass,true,pluginLoaders[pluginName])
return pluginLoaders[pluginName]!!.loadClass(mainClass)
}catch (e : ClassNotFoundException){
throw ClassNotFoundException("PluginsClassLoader(${pluginName}) can't load this pluginMainClass:${mainClass}",e)
}catch (e : Throwable){