diff --git a/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java b/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
index 0d6ee82c6d..6d36406dff 100644
--- a/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
+++ b/jme3-android/src/main/java/com/jme3/system/android/JmeAndroidSystem.java
@@ -17,7 +17,7 @@
import com.jme3.system.*;
import com.jme3.system.JmeContext.Type;
import com.jme3.util.AndroidScreenshots;
-import com.jme3.util.functional.VoidFunction;
+import com.jme3.util.res.ResourcesLoader;
import java.io.File;
import java.io.IOException;
@@ -52,7 +52,7 @@ public JmeAndroidSystem(){
@Override
public URL getPlatformAssetConfigURL() {
- return Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Android.cfg");
+ return ResourcesLoader.getResource("com/jme3/asset/Android.cfg");
}
@Override
diff --git a/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java b/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java
index bc2b2bb52c..8578c6e9d1 100644
--- a/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java
+++ b/jme3-core/src/main/java/com/jme3/app/LegacyApplication.java
@@ -47,6 +47,8 @@
import com.jme3.renderer.ViewPort;
import com.jme3.system.*;
import com.jme3.system.JmeContext.Type;
+import com.jme3.util.res.ResourcesLoader;
+
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.Callable;
@@ -206,14 +208,14 @@ private void initAssetManager() {
} catch (MalformedURLException ex) {
}
if (assetCfgUrl == null) {
- assetCfgUrl = LegacyApplication.class.getClassLoader().getResource(assetCfg);
+ assetCfgUrl = ResourcesLoader.getResource(assetCfg);
if (assetCfgUrl == null) {
logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
return;
}
}
}
- }
+ }
if (assetCfgUrl == null) {
assetCfgUrl = JmeSystem.getPlatformAssetConfigURL();
}
diff --git a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
index be2c834ea9..3bcb0d06f0 100644
--- a/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
+++ b/jme3-core/src/main/java/com/jme3/asset/AssetConfig.java
@@ -39,6 +39,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.jme3.util.res.ResourcesLoader;
+
/**
* AssetConfig
loads a config file to configure the asset manager.
*
@@ -101,7 +103,7 @@ public static void loadText(AssetManager assetManager, URL configUrl) throws IOE
}
} else if (cmd.equals("INCLUDE")) {
String includedCfg = scan.nextLine().trim();
- URL includedCfgUrl = Thread.currentThread().getContextClassLoader().getResource(includedCfg);
+ URL includedCfgUrl = ResourcesLoader.getResource(includedCfg);
if (includedCfgUrl != null) {
loadText(assetManager, includedCfgUrl);
} else {
diff --git a/jme3-core/src/main/java/com/jme3/asset/AssetManager.java b/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
index cde85ecec1..674985f104 100644
--- a/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
+++ b/jme3-core/src/main/java/com/jme3/asset/AssetManager.java
@@ -46,6 +46,7 @@
import com.jme3.texture.plugins.TGALoader;
import java.io.IOException;
import java.io.InputStream;
+import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
@@ -86,7 +87,7 @@
* so that modifications to one instance do not leak onto others.
*/
public interface AssetManager {
-
+
/**
* Adds a {@link ClassLoader} that is used to load {@link Class classes}
* that are needed for finding and loading Assets.
@@ -94,23 +95,35 @@ public interface AssetManager {
* use registerLocator for that.
*
* @param loader A ClassLoader that Classes in asset files can be loaded from.
+ * @deprecated use {@link com.jme3.util.res.ResourcesLoader}
*/
- public void addClassLoader(ClassLoader loader);
+ @Deprecated
+ public default void addClassLoader(ClassLoader loader) {
+
+ }
/**
* Remove a {@link ClassLoader} from the list of registered ClassLoaders
*
* @param loader the ClassLoader to be removed
+ * @deprecated use {@link com.jme3.util.res.ResourcesLoader}
*/
- public void removeClassLoader(ClassLoader loader);
+ @Deprecated
+ public default void removeClassLoader(ClassLoader loader) {
+
+ }
/**
* Retrieve the list of registered ClassLoaders that are used for loading
* {@link Class classes} from asset files.
*
* @return an unmodifiable list
+ * @deprecated use {@link com.jme3.util.res.ResourcesLoader}
*/
- public List getClassLoaders();
+ @Deprecated
+ public default List getClassLoaders() {
+ return new ArrayList<>();
+ }
/**
* Register an {@link AssetLoader} by using a class object.
diff --git a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java
index c81e56fec5..a8ff73f2c4 100644
--- a/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java
+++ b/jme3-core/src/main/java/com/jme3/asset/DesktopAssetManager.java
@@ -73,8 +73,8 @@ public class DesktopAssetManager implements AssetManager {
final private CopyOnWriteArrayList eventListeners =
new CopyOnWriteArrayList<>();
- final private List classLoaders =
- Collections.synchronizedList(new ArrayList<>());
+ @Deprecated
+ final private List classLoaders = Collections.synchronizedList(new ArrayList<>());
public DesktopAssetManager() {
this(null);
@@ -99,21 +99,23 @@ private void loadConfigFile(URL configFile) {
}
}
+ @Deprecated
@Override
public void addClassLoader(ClassLoader loader) {
classLoaders.add(loader);
}
+ @Deprecated
@Override
public void removeClassLoader(ClassLoader loader) {
classLoaders.remove(loader);
}
+ @Deprecated
@Override
public List getClassLoaders() {
return Collections.unmodifiableList(classLoaders);
}
-
@Override
public void addAssetEventListener(AssetEventListener listener) {
eventListeners.add(listener);
diff --git a/jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java b/jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java
index 81887511cf..2c63050a4d 100644
--- a/jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java
+++ b/jme3-core/src/main/java/com/jme3/export/SavableClassUtil.java
@@ -201,6 +201,10 @@ public static Savable fromName(String className)
}
}
+ /**
+ * @deprecated use {@link #fromName(java.lang.String)} instead
+ */
+ @Deprecated
public static Savable fromName(String className, List loaders) throws InstantiationException,
InvocationTargetException, NoSuchMethodException,
IllegalAccessException, ClassNotFoundException, IOException {
diff --git a/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java b/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java
index 105440855d..97043ac6fb 100644
--- a/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java
+++ b/jme3-core/src/main/java/com/jme3/input/JoystickCompatibilityMappings.java
@@ -44,6 +44,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import com.jme3.util.res.ResourcesLoader;
+
/**
* Provides compatibility mapping to different joysticks
@@ -554,9 +556,9 @@ public static void loadMappingProperties(URL u) throws IOException {
}
}
- protected static void loadMappings(ClassLoader cl, String path) throws IOException {
+ protected static void loadMappings(String path) throws IOException {
logger.log(Level.FINE, "Searching for mappings for path:{0}", path);
- for (Enumeration en = cl.getResources(path); en.hasMoreElements(); ) {
+ for (Enumeration en = ResourcesLoader.getResources(path); en.hasMoreElements(); ) {
URL u = en.nextElement();
try {
loadMappingProperties(u);
@@ -574,7 +576,7 @@ protected static void loadMappings(ClassLoader cl, String path) throws IOExcepti
protected static void loadDefaultMappings() {
for (String s : searchPaths) {
try {
- loadMappings(JoystickCompatibilityMappings.class.getClassLoader(), s);
+ loadMappings(s);
} catch (IOException e) {
logger.log(Level.SEVERE, "Error searching resource path:{0}", s);
}
diff --git a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
index 35143fca4a..f6028e4b3d 100644
--- a/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
+++ b/jme3-core/src/main/java/com/jme3/system/JmeSystemDelegate.java
@@ -35,6 +35,7 @@
import com.jme3.asset.DesktopAssetManager;
import com.jme3.audio.AudioRenderer;
import com.jme3.input.SoftTextDialogInput;
+import com.jme3.util.res.ResourcesLoader;
import java.io.File;
import java.io.IOException;
@@ -126,11 +127,11 @@ public String getFullName() {
}
public InputStream getResourceAsStream(String name) {
- return this.getClass().getResourceAsStream(name);
+ return ResourcesLoader.getResourceAsStream(name,this.getClass());
}
public URL getResource(String name) {
- return this.getClass().getResource(name);
+ return ResourcesLoader.getResource(name,this.getClass());
}
public boolean trackDirectMemory() {
diff --git a/jme3-core/src/main/java/com/jme3/system/JmeVersion.java b/jme3-core/src/main/java/com/jme3/system/JmeVersion.java
index f15bc2dcff..e26251d379 100644
--- a/jme3-core/src/main/java/com/jme3/system/JmeVersion.java
+++ b/jme3-core/src/main/java/com/jme3/system/JmeVersion.java
@@ -36,6 +36,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.jme3.util.res.ResourcesLoader;
+
/**
* Pulls in version info from the version.properties file.
*
@@ -48,7 +50,7 @@ public class JmeVersion {
static {
try {
- props.load(JmeVersion.class.getResourceAsStream("version.properties"));
+ props.load(ResourcesLoader.getResourceAsStream("version.properties",JmeVersion.class));
} catch (IOException | NullPointerException ex) {
logger.log(Level.WARNING, "Unable to read version info!", ex);
}
diff --git a/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoader.java b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoader.java
new file mode 100644
index 0000000000..565c3702ba
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoader.java
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.util.res;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+
+/**
+ * This class is used to load resources from the default location
+ * usually the classpath.
+ */
+public class ResourcesLoader {
+ public static final String PROPERTY_RESOURCES_LOADER_IMPLEMENTATION = "com.jme3.ResourcesLoaderImplementation";
+ private static final String DEFAULT_IMPL = "com.jme3.util.res.ResourcesLoaderJImpl";
+
+ private static final Logger LOGGER = Logger.getLogger(ResourcesLoader.class.getName());
+ private static ResourcesLoaderImpl impl = null;
+
+ private static ResourcesLoaderImpl getImpl() {
+ if (impl != null) return impl;
+ String className = System.getProperty(PROPERTY_RESOURCES_LOADER_IMPLEMENTATION, DEFAULT_IMPL);
+ try {
+ impl = (ResourcesLoaderImpl) Class.forName(className).getDeclaredConstructor().newInstance();
+ } catch (final Throwable e) {
+ LOGGER.log(Level.WARNING, "Unable to access {0}", className);
+ try {
+ impl = (ResourcesLoaderImpl) Class.forName(DEFAULT_IMPL).getDeclaredConstructor().newInstance();
+ } catch (final Throwable e1) {
+ throw new RuntimeException("Unable to access default resources loader implementation", e1);
+ }
+ }
+ return impl;
+ }
+
+ public static void setImpl(ResourcesLoaderImpl impl) {
+ ResourcesLoader.impl = impl;
+ }
+
+
+ public static URL getResource(String path) {
+ return getImpl().getResource(path, null);
+ }
+
+
+ public static URL getResource(String path, Class> parent) {
+ return getImpl().getResource(path, parent);
+ }
+
+ public static InputStream getResourceAsStream(String path) {
+ return getImpl().getResourceAsStream(path, null);
+ }
+
+ public static InputStream getResourceAsStream(String path,Class> clazz) {
+ return getImpl().getResourceAsStream(path,clazz);
+ }
+
+
+ public static Enumeration getResources(String path ) throws IOException {
+ return getImpl().getResources(path,null);
+ }
+
+
+ public static Enumeration getResources(String path,Class> clazz) throws IOException {
+ return getImpl().getResources(path,clazz);
+ }
+}
diff --git a/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderImpl.java b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderImpl.java
new file mode 100644
index 0000000000..33034c71af
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderImpl.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.util.res;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+public interface ResourcesLoaderImpl {
+ public URL getResource(String path, Class> clazz);
+ public InputStream getResourceAsStream(String path, Class> clazz);
+ public Enumeration getResources(String path, Class> clazz) throws IOException;
+}
diff --git a/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderJImpl.java b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderJImpl.java
new file mode 100644
index 0000000000..7a5737aa6a
--- /dev/null
+++ b/jme3-core/src/main/java/com/jme3/util/res/ResourcesLoaderJImpl.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2009-2023 jMonkeyEngine
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.jme3.util.res;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+
+/**
+ * Default java-like implementation of ResourceLoaderImpl.
+ * Loads from classpath.
+ */
+public class ResourcesLoaderJImpl implements ResourcesLoaderImpl {
+
+ public InputStream getResourceAsStream(String path, Class> parent) {
+ if (parent == null) {
+ return Thread.currentThread().getContextClassLoader().getResourceAsStream(path);
+ } else {
+ return parent.getResourceAsStream(path);
+ }
+ }
+
+ @Override
+ public URL getResource(String path, Class> parent) {
+ if (parent == null) {
+ return Thread.currentThread().getContextClassLoader().getResource(path);
+ } else {
+ return parent.getResource(path);
+ }
+ }
+
+ @Override
+ public Enumeration getResources(String path, Class> parent) throws IOException {
+ if (parent == null) {
+ return Thread.currentThread().getContextClassLoader().getResources(path);
+ } else {
+ if (!path.startsWith("/")) {
+ Class> c = parent;
+ while (c.isArray()) {
+ c = c.getComponentType();
+ }
+ String baseName = c.getName();
+ int index = baseName.lastIndexOf('.');
+ if (index != -1) {
+ path = baseName.substring(0, index).replace('.', '/') + "/" + path;
+ }
+ } else {
+ path = path.substring(1);
+ }
+ return parent.getClassLoader().getResources(path);
+ }
+ }
+
+}
diff --git a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
index dbdd33c65a..28c6acfeef 100644
--- a/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
+++ b/jme3-core/src/plugins/java/com/jme3/asset/plugins/ClasspathLocator.java
@@ -33,6 +33,8 @@
import com.jme3.asset.*;
import com.jme3.system.JmeSystem;
+import com.jme3.util.res.ResourcesLoader;
+
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
@@ -87,20 +89,10 @@ public AssetInfo locate(AssetManager manager, AssetKey key) {
// name = root + name;
// }
- if (JmeSystem.isLowPermissions()){
- url = ClasspathLocator.class.getResource("/" + name);
- }else{
- url = Thread.currentThread().getContextClassLoader().getResource(name);
- }
-
- if (url == null) {
- final List classLoaders = manager.getClassLoaders();
- for (final ClassLoader classLoader : classLoaders) {
- url = classLoader.getResource(name);
- if(url != null) {
- break;
- }
- }
+ if (JmeSystem.isLowPermissions()) {
+ url = ResourcesLoader.getResource("/" + name, ClasspathLocator.class);
+ } else {
+ url = ResourcesLoader.getResource( name);
}
if (url == null)
diff --git a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
index 42a2be80e7..0be52a8192 100644
--- a/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
+++ b/jme3-core/src/plugins/java/com/jme3/export/binary/BinaryImporter.java
@@ -329,12 +329,7 @@ public Savable readObject(int id) {
int dataLength = ByteUtils.convertIntFromBytes(dataArray, loc);
loc+=4;
- Savable out = null;
- if (assetManager != null) {
- out = SavableClassUtil.fromName(bco.className, assetManager.getClassLoaders());
- } else {
- out = SavableClassUtil.fromName(bco.className);
- }
+ Savable out = SavableClassUtil.fromName(bco.className);
BinaryInputCapsule cap = new BinaryInputCapsule(this, out, bco);
cap.setContent(dataArray, loc, loc+dataLength);
diff --git a/jme3-core/src/test/java/com/jme3/system/MockJmeSystemDelegate.java b/jme3-core/src/test/java/com/jme3/system/MockJmeSystemDelegate.java
index ca981877eb..cce506e932 100644
--- a/jme3-core/src/test/java/com/jme3/system/MockJmeSystemDelegate.java
+++ b/jme3-core/src/test/java/com/jme3/system/MockJmeSystemDelegate.java
@@ -32,6 +32,8 @@
package com.jme3.system;
import com.jme3.audio.AudioRenderer;
+import com.jme3.util.res.ResourcesLoader;
+
import java.io.IOException;
import java.io.OutputStream;
import java.net.URL;
@@ -45,7 +47,7 @@ public void writeImageFile(OutputStream outStream, String format, ByteBuffer ima
@Override
public URL getPlatformAssetConfigURL() {
- return Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/General.cfg");
+ return ResourcesLoader.getResource("com/jme3/asset/General.cfg");
}
@Override
diff --git a/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java b/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java
index 2ce2a55885..e35d10a662 100644
--- a/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java
+++ b/jme3-desktop/src/main/java/com/jme3/app/AppletHarness.java
@@ -34,6 +34,8 @@
import com.jme3.system.AppSettings;
import com.jme3.system.JmeCanvasContext;
import com.jme3.system.JmeSystem;
+import com.jme3.util.res.ResourcesLoader;
+
import java.applet.Applet;
import java.awt.Canvas;
import java.awt.Graphics;
@@ -150,7 +152,7 @@ public void init(){
assetCfg = new URL(getParameter("AssetConfigURL"));
} catch (MalformedURLException ex){
System.out.println(ex.getMessage());
- assetCfg = getClass().getResource("/com/jme3/asset/Desktop.cfg");
+ assetCfg = ResourcesLoader.getResource("/com/jme3/asset/Desktop.cfg",this.getClass());
}
createCanvas();
diff --git a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
index 645a83b9ed..0ea862f240 100644
--- a/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
+++ b/jme3-desktop/src/main/java/com/jme3/system/JmeDesktopSystem.java
@@ -39,6 +39,8 @@
import com.jme3.system.JmeContext.Type;
import com.jme3.texture.Image;
import com.jme3.texture.image.ColorSpace;
+import com.jme3.util.res.ResourcesLoader;
+
import jme3tools.converters.ImageToAwt;
import javax.imageio.IIOImage;
@@ -70,7 +72,7 @@ public JmeDesktopSystem() {
@Override
public URL getPlatformAssetConfigURL() {
- return Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/Desktop.cfg");
+ return ResourcesLoader.getResource("com/jme3/asset/Desktop.cfg");
}
private static BufferedImage verticalFlip(BufferedImage original) {
diff --git a/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java b/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
index 85810d4164..2becc5214f 100644
--- a/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
+++ b/jme3-desktop/src/main/java/com/jme3/system/NativeLibraryLoader.java
@@ -44,6 +44,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;
+import com.jme3.util.res.ResourcesLoader;
+
/**
* Utility class to register, extract, and load native libraries.
*
@@ -274,7 +276,7 @@ private static void setExtractionFolderToUserCache() {
private static int computeNativesHash() {
URLConnection conn = null;
String classpath = System.getProperty("java.class.path");
- URL url = Thread.currentThread().getContextClassLoader().getResource("com/jme3/system/NativeLibraryLoader.class");
+ URL url = ResourcesLoader.getResource("com/jme3/system/NativeLibraryLoader.class");
try {
StringBuilder sb = new StringBuilder(url.toString());
@@ -371,9 +373,9 @@ public static File getJarForNativeLibrary(Platform platform, String name) {
fileNameInJar = pathInJar;
}
- URL url = Thread.currentThread().getContextClassLoader().getResource(pathInJar);
+ URL url = ResourcesLoader.getResource(pathInJar);
if (url == null) {
- url = Thread.currentThread().getContextClassLoader().getResource(fileNameInJar);
+ url = ResourcesLoader.getResource(fileNameInJar);
}
if (url == null) {
@@ -401,7 +403,7 @@ public static void extractNativeLibrary(Platform platform, String name, File tar
return;
}
- URL url = Thread.currentThread().getContextClassLoader().getResource(pathInJar);
+ URL url = ResourcesLoader.getResource(pathInJar);
if (url == null) {
return;
}
@@ -462,7 +464,7 @@ public static void loadNativeLibrary(String name, boolean isRequired) {
return;
}
- URL url = Thread.currentThread().getContextClassLoader().getResource(pathInJar);
+ URL url = ResourcesLoader.getResource(pathInJar);
if (url == null) {
if (isRequired) {
diff --git a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
index 77f41c1f82..90d601d961 100644
--- a/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
+++ b/jme3-ios/src/main/java/com/jme3/system/ios/JmeIosSystem.java
@@ -35,7 +35,7 @@
import com.jme3.system.JmeContext;
import com.jme3.system.JmeSystemDelegate;
import com.jme3.system.NullContext;
-import com.jme3.util.functional.VoidFunction;
+import com.jme3.util.res.ResourcesLoader;
import com.jme3.audio.AudioRenderer;
import com.jme3.audio.ios.IosAL;
import com.jme3.audio.ios.IosALC;
@@ -64,7 +64,7 @@ public JmeIosSystem() {
@Override
public URL getPlatformAssetConfigURL() {
- return Thread.currentThread().getContextClassLoader().getResource("com/jme3/asset/IOS.cfg");
+ return ResourcesLoader.getResource("com/jme3/asset/IOS.cfg");
}
@Override
diff --git a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java
index 52cd509f10..245bcdacbf 100644
--- a/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java
+++ b/jme3-plugins/src/xml/java/com/jme3/export/xml/DOMInputCapsule.java
@@ -924,7 +924,7 @@ private Savable readSavableFromCurrentElem(Savable defVal) throws
} else if (defVal != null) {
className = defVal.getClass().getName();
}
- tmp = SavableClassUtil.fromName(className, null);
+ tmp = SavableClassUtil.fromName(className);
String versionsStr = currentElem.getAttribute("savable_versions");
if (versionsStr != null && !versionsStr.equals("")){
diff --git a/jme3-vr/src/main/java/com/jme3/app/VRApplication.java b/jme3-vr/src/main/java/com/jme3/app/VRApplication.java
index 02ab733230..6b20bddee5 100644
--- a/jme3-vr/src/main/java/com/jme3/app/VRApplication.java
+++ b/jme3-vr/src/main/java/com/jme3/app/VRApplication.java
@@ -49,6 +49,7 @@
import com.jme3.system.lwjgl.LwjglOffscreenBufferVR;
import com.jme3.util.VRGUIPositioningMode;
import com.jme3.util.VRGuiManager;
+import com.jme3.util.res.ResourcesLoader;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
@@ -1177,7 +1178,7 @@ private void initAssetManager(){
} catch (MalformedURLException ex) {
}
if (assetCfgUrl == null) {
- assetCfgUrl = LegacyApplication.class.getClassLoader().getResource(assetCfg);
+ assetCfgUrl = ResourcesLoader.getResource(assetCfg);
if (assetCfgUrl == null) {
logger.log(Level.SEVERE, "Unable to access AssetConfigURL in asset config:{0}", assetCfg);
return;