mirror of
https://github.com/tursom/TursomServer.git
synced 2024-12-29 14:30:55 +08:00
update ListClassLoader
This commit is contained in:
parent
7b47f3382a
commit
f42934be66
@ -1,23 +1,23 @@
|
||||
package cn.tursom.core
|
||||
|
||||
import java.net.URL
|
||||
import java.net.URLClassLoader
|
||||
|
||||
|
||||
@Suppress("unused")
|
||||
class ListClassLoader(url: Array<out URL>, parent: ClassLoader? = null) : URLClassLoader(url, parent) {
|
||||
private val parentList = ArrayList<ClassLoader>()
|
||||
val parents: List<ClassLoader> get() = parentList
|
||||
class ListClassLoader(
|
||||
//url: Array<out URL>,
|
||||
parent: ClassLoader = getSystemClassLoader()
|
||||
) : ClassLoader(parent),
|
||||
MutableList<ClassLoader> by ArrayList() {
|
||||
|
||||
fun addParent(parent: ClassLoader) = parentList.add(parent)
|
||||
fun removeParent(parent: ClassLoader) = parentList.remove(parent)
|
||||
val parents: List<ClassLoader> get() = this
|
||||
|
||||
fun addParent(parent: ClassLoader) = add(parent)
|
||||
fun removeParent(parent: ClassLoader) = remove(parent)
|
||||
|
||||
override fun findClass(name: String?): Class<*> {
|
||||
try {
|
||||
return super.findClass(name)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
}
|
||||
parentList.forEach {
|
||||
forEach {
|
||||
try {
|
||||
return it.loadClass(name)
|
||||
} catch (e: ClassNotFoundException) {
|
||||
|
Loading…
Reference in New Issue
Block a user