fixed two problems with asset manager:

1. can't load classes from asset class loaders.
2. can't load resources from asset class loaders.
fix-456
javasabr 8 years ago committed by Rémy Bouquet
parent abab0a553f
commit fac8266b5c
  1. 14
      jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java
  2. 12
      jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java

@ -34,6 +34,7 @@ package com.jme3.export;
import com.jme3.animation.Animation;
import com.jme3.effect.shapes.*;
import com.jme3.material.MatParamTexture;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
@ -189,14 +190,19 @@ public class SavableClassUtil {
}
String newClassName = remapClass(className);
synchronized(loaders) {
for (ClassLoader classLoader : loaders){
synchronized (loaders) {
for (ClassLoader classLoader : loaders) {
final Class<?> loadedClass;
try {
loadedClass = classLoader.loadClass(newClassName);
} catch (final ClassNotFoundException e) {
continue;
}
try {
return (Savable) classLoader.loadClass(newClassName).newInstance();
return (Savable) loadedClass.newInstance();
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
}
}
}

@ -37,6 +37,7 @@ import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.logging.Logger;
/**
@ -90,6 +91,17 @@ public class ClasspathLocator implements AssetLocator {
}else{
url = Thread.currentThread().getContextClassLoader().getResource(name);
}
if (url == null) {
final List<ClassLoader> classLoaders = manager.getClassLoaders();
for (final ClassLoader classLoader : classLoaders) {
url = classLoader.getResource(name);
if(url != null) {
break;
}
}
}
if (url == null)
return null;

Loading…
Cancel
Save