always try loading classpath jars as modules
import java.lang.reflect.ReflectPermission;
import java.net.URISyntaxException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.security.Policy;
@@ -130,16 +129,14 @@ public ModuleManagerImpl(Config config, List<Class<?>> classesOnClasspathsToAddT
* Overrides modules in modules/ with those specified via -classpath in the JVM
*/
private void loadModulesFromClassPath() {
- // Only attempt this if we're using the standard URLClassLoader
- if (ClassLoader.getSystemClassLoader() instanceof URLClassLoader) {
- URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
+ ClassLoader classLoader = ClassLoader.getSystemClassLoader();
ModuleLoader loader = new ModuleLoader(metadataReader);
Enumeration<URL> moduleInfosInClassPath;
loader.setModuleInfoPath(TerasologyConstants.MODULE_INFO_FILENAME);
// We're looking for jars on the classpath with a module.txt
try {
- moduleInfosInClassPath = urlClassLoader.findResources(TerasologyConstants.MODULE_INFO_FILENAME.toString());
+ moduleInfosInClassPath = classLoader.getResources(TerasologyConstants.MODULE_INFO_FILENAME.toString());
} catch (IOException e) {
logger.warn("Failed to search for classpath modules: {}", e);
return;
@@ -185,7 +182,6 @@ private void loadModulesFromClassPath() {
}
}
}
- }
private void setupSandbox() {
ExternalApiWhitelist.CLASSES.stream().forEach(clazz ->
