Fix package private resolution of fields/methods from base minecraft by loading into minecraft's class loader not our own

This commit is contained in:
Christian Weeks 2012-04-06 13:27:50 -04:00
parent 21d11f431f
commit 71a9bf9f70
1 changed files with 14 additions and 2 deletions

View File

@ -14,6 +14,7 @@
package cpw.mods.fml.common;
import java.io.File;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
@ -36,8 +37,19 @@ public class ModClassLoader extends URLClassLoader
public void addFile(File modFile) throws MalformedURLException
{
URL url = modFile.toURI().toURL();
super.addURL(url);
ClassLoader cl=getParent();
if (cl instanceof URLClassLoader) {
URLClassLoader ucl=(URLClassLoader) cl;
URL url = modFile.toURI().toURL();
try {
Method addUrl=URLClassLoader.class.getMethod("addUrl", URL.class);
addUrl.setAccessible(true);
addUrl.invoke(ucl, url);
} catch (Exception e) {
Loader.log.severe("A fatal error occured attempting to load a file into the classloader");
throw new LoaderException(e);
}
}
}
public File getParentSource() {