Fixed #5414
This commit is contained in:
@@ -4,7 +4,12 @@ import arc.struct.*;
|
|||||||
|
|
||||||
public class ModClassLoader extends ClassLoader{
|
public class ModClassLoader extends ClassLoader{
|
||||||
private Seq<ClassLoader> children = new Seq<>();
|
private Seq<ClassLoader> children = new Seq<>();
|
||||||
private volatile boolean inChild = false;
|
private ThreadLocal<Boolean> inChild = new ThreadLocal<>(){
|
||||||
|
@Override
|
||||||
|
protected Boolean initialValue(){
|
||||||
|
return Boolean.FALSE;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public void addChild(ClassLoader child){
|
public void addChild(ClassLoader child){
|
||||||
children.add(child);
|
children.add(child);
|
||||||
@@ -13,15 +18,15 @@ public class ModClassLoader extends ClassLoader{
|
|||||||
@Override
|
@Override
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException{
|
protected Class<?> findClass(String name) throws ClassNotFoundException{
|
||||||
//a child may try to delegate class loading to its parent, which is *this class loader* - do not let that happen
|
//a child may try to delegate class loading to its parent, which is *this class loader* - do not let that happen
|
||||||
if(inChild){
|
if(inChild.get()){
|
||||||
inChild = false;
|
inChild.set(false);
|
||||||
throw new ClassNotFoundException(name);
|
throw new ClassNotFoundException(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassNotFoundException last = null;
|
ClassNotFoundException last = null;
|
||||||
int size = children.size;
|
int size = children.size;
|
||||||
|
|
||||||
inChild = true;
|
inChild.set(true);
|
||||||
//if it doesn't exist in the main class loader, try all the children
|
//if it doesn't exist in the main class loader, try all the children
|
||||||
for(int i = 0; i < size; i++){
|
for(int i = 0; i < size; i++){
|
||||||
try{
|
try{
|
||||||
@@ -30,7 +35,7 @@ public class ModClassLoader extends ClassLoader{
|
|||||||
last = e;
|
last = e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inChild = false;
|
inChild.set(false);
|
||||||
|
|
||||||
throw (last == null ? new ClassNotFoundException(name) : last);
|
throw (last == null ? new ClassNotFoundException(name) : last);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ kapt.use.worker.api=true
|
|||||||
kapt.include.compile.classpath=false
|
kapt.include.compile.classpath=false
|
||||||
# I don't need to use the kotlin stdlib yet, so remove it to prevent extra bloat & method count issues
|
# I don't need to use the kotlin stdlib yet, so remove it to prevent extra bloat & method count issues
|
||||||
kotlin.stdlib.default.dependency=false
|
kotlin.stdlib.default.dependency=false
|
||||||
archash=ea70a34cc621c2c75d0aef5511c7f5aa4ced0d46
|
archash=3926b785320fea0cd9ca597f6bfa9071263a5464
|
||||||
|
|||||||
Reference in New Issue
Block a user