- synchronized access to AssetManager ClassLoader list

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8606 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 13 years ago
parent c0695b0a3a
commit 23b4e2fcf0
  1. 2
      engine/src/core/com/jme3/export/SavableClassUtil.java
  2. 5
      engine/src/desktop/com/jme3/asset/DesktopAssetManager.java

@ -185,6 +185,7 @@ public class SavableClassUtil {
} }
String newClassName = remapClass(className); String newClassName = remapClass(className);
synchronized(loaders) {
for (ClassLoader classLoader : loaders){ for (ClassLoader classLoader : loaders){
try { try {
return (Savable) classLoader.loadClass(newClassName).newInstance(); return (Savable) classLoader.loadClass(newClassName).newInstance();
@ -193,6 +194,7 @@ public class SavableClassUtil {
} }
} }
}
return fromName(className); return fromName(className);
} }

@ -102,13 +102,16 @@ public class DesktopAssetManager implements AssetManager {
public void addClassLoader(ClassLoader loader){ public void addClassLoader(ClassLoader loader){
if(classLoaders == null) if(classLoaders == null)
classLoaders = Collections.synchronizedList(new ArrayList<ClassLoader>()); classLoaders = Collections.synchronizedList(new ArrayList<ClassLoader>());
synchronized(classLoaders) {
classLoaders.add(loader); classLoaders.add(loader);
} }
}
public void removeClassLoader(ClassLoader loader){ public void removeClassLoader(ClassLoader loader){
if(classLoaders != null) if(classLoaders != null) synchronized(classLoaders) {
classLoaders.remove(loader); classLoaders.remove(loader);
} }
}
public List<ClassLoader> getClassLoaders(){ public List<ClassLoader> getClassLoaders(){
return classLoaders; return classLoaders;

Loading…
Cancel
Save