Use the negative cache in latest legacylauncher.

This commit is contained in:
Christian committed 2013-09-25 11:46:11 -04:00
1 parent 8e26c99de3
commit 1d902df581
6 files changed
+31 -6

No files matched your search

@@ -54,6 +54,7 @@ import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.Metadata;
import cpw.mods.fml.common.discovery.ASMDataTable;
import cpw.mods.fml.common.discovery.ASMDataTable.ASMData;
import cpw.mods.fml.common.discovery.ModCandidate;
import cpw.mods.fml.common.event.FMLConstructionEvent;
import cpw.mods.fml.common.event.FMLEvent;
import cpw.mods.fml.common.event.FMLInitializationEvent;
@@ -112,11 +113,13 @@ public class FMLModContainer implements ModContainer
private ILanguageAdapter languageAdapter;
private ListMultimap<Class<? extends FMLEvent>,Method> eventMethods;
private Map<String, String> customModProperties;
private ModCandidate candidate;
public FMLModContainer(String className, File modSource, Map<String,Object> modDescriptor)
public FMLModContainer(String className, ModCandidate container, Map<String,Object> modDescriptor)
{
this.className = className;
this.source = modSource;
this.source = container.getModContainer();
this.candidate = container;
this.descriptor = modDescriptor;
this.modLanguage = (String) modDescriptor.get("modLanguage");
this.languageAdapter = "scala".equals(modLanguage) ? new ILanguageAdapter.ScalaAdapter() : new ILanguageAdapter.JavaAdapter();
@@ -454,6 +457,7 @@ public class FMLModContainer implements ModContainer
{
ModClassLoader modClassLoader = event.getModClassLoader();
modClassLoader.addFile(source);
modClassLoader.clearNegativeCacheFor(candidate.getClassList());
Class<?> clazz = Class.forName(className, true, modClassLoader);
Certificate[] certificates = clazz.getProtectionDomain().getCodeSource().getCertificates();
@@ -18,6 +18,7 @@ import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import net.minecraft.launchwrapper.IClassTransformer;
@@ -100,4 +101,9 @@ public class ModClassLoader extends URLClassLoader
accessTransformer.ensurePublicAccessFor(modClazzName);
return (Class<? extends BaseModProxy>) Class.forName(modClazzName, true, this);
}
public void clearNegativeCacheFor(Set<String> classList)
{
mainClassLoader.clearNegativeEntries(classList);
}
}
@@ -5,7 +5,7 @@
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*
* Contributors:
* cpw - implementation
*/
@@ -61,7 +61,7 @@ public class ModContainerFactory
if (ann.getASMType().equals(Type.getType(Mod.class)))
{
FMLLog.fine("Identified an FMLMod type mod %s", className);
return new FMLModContainer(className, modSource, ann.getValues());
return new FMLModContainer(className, container, ann.getValues());
}
}
@@ -5,7 +5,7 @@
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*
* Contributors:
* cpw - implementation
*/
@@ -98,6 +98,7 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
FileInputStream fis = new FileInputStream(file);
modParser = new ASMModParser(fis);
fis.close();
candidate.addClassEntry(path+file.getName());
}
catch (LoaderException e)
{
@@ -70,6 +70,7 @@ public class JarDiscoverer implements ITypeDiscoverer
try
{
modParser = new ASMModParser(jar.getInputStream(ze));
candidate.addClassEntry(ze.getName());
}
catch (LoaderException e)
{
@@ -5,7 +5,7 @@
* are made available under the terms of the GNU Lesser Public License v2.1
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
*
* Contributors:
* cpw - implementation
*/
@@ -14,8 +14,10 @@ package cpw.mods.fml.common.discovery;
import java.io.File;
import java.util.List;
import java.util.Set;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.ModContainer;
@@ -31,6 +33,7 @@ public class ModCandidate
private List<String> baseModTypes = Lists.newArrayList();
private boolean isMinecraft;
private List<ASMModParser> baseModCandidateTypes = Lists.newArrayListWithCapacity(1);
private Set<String> foundClasses = Sets.newHashSet();
public ModCandidate(File classPathRoot, File modContainer, ContainerType sourceType)
{
@@ -73,6 +76,12 @@ public class ModCandidate
}
}
public void addClassEntry(String name)
{
String className = name.substring(0, name.lastIndexOf('.')).replace('.', '/'); // strip the .class and . -> /
foundClasses.add(className);
}
public boolean isClasspath()
{
return classpath;
@@ -93,4 +102,8 @@ public class ModCandidate
{
baseModCandidateTypes.add(modParser);
}
public Set<String> getClassList()
{
return foundClasses;
}
}