Fix classloading issues in userdev (and possibly also for things like tests within forgedev) (#5275)

This commit is contained in:
David Quintana authored and LexManos committed 2018-12-13 15:33:35 -08:00
1 parent f13465012b
commit 52b6da1759
3 files changed
+54 -21

No files matched your search

@@ -33,7 +33,6 @@ import static net.minecraftforge.fml.Logging.LOADING;
public class ModLoadingClassLoader extends SecureClassLoader
{
private static final Logger LOGGER = LogManager.getLogger();
static {
@@ -50,6 +49,18 @@ public class ModLoadingClassLoader extends SecureClassLoader
return super.getResource(name);
}
@Override
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException
{
final String className = name.replace('.', '/').concat(".class");
final Path classResource = FMLLoader.getLoadingModList().findResource(className);
if (classResource != null)
{
return findClass(name);
}
return super.loadClass(name, resolve);
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException
{
@@ -65,7 +76,7 @@ public class ModLoadingClassLoader extends SecureClassLoader
{
throw new ClassNotFoundException("Failed to load class file " + classResource + " for "+ className, e);
}
} else {
} else if(getParent() != null) {
getParent().loadClass(name);
}
throw new ClassNotFoundException("Failed to find class file "+ className);