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:
parent
21d11f431f
commit
71a9bf9f70
|
@ -14,6 +14,7 @@
|
||||||
package cpw.mods.fml.common;
|
package cpw.mods.fml.common;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
@ -36,8 +37,19 @@ public class ModClassLoader extends URLClassLoader
|
||||||
|
|
||||||
public void addFile(File modFile) throws MalformedURLException
|
public void addFile(File modFile) throws MalformedURLException
|
||||||
{
|
{
|
||||||
URL url = modFile.toURI().toURL();
|
ClassLoader cl=getParent();
|
||||||
super.addURL(url);
|
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() {
|
public File getParentSource() {
|
||||||
|
|
Loading…
Reference in New Issue