More precise error handling when an invalid class is present
This commit is contained in:
parent
4d44836bb3
commit
f0d5732477
3 changed files with 33 additions and 5 deletions
|
@ -5,12 +5,14 @@ import java.io.FileFilter;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import com.google.common.base.Throwables;
|
import com.google.common.base.Throwables;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.LoaderException;
|
||||||
import cpw.mods.fml.common.MetadataCollection;
|
import cpw.mods.fml.common.MetadataCollection;
|
||||||
import cpw.mods.fml.common.ModContainer;
|
import cpw.mods.fml.common.ModContainer;
|
||||||
import cpw.mods.fml.common.ModContainerFactory;
|
import cpw.mods.fml.common.ModContainerFactory;
|
||||||
|
@ -85,6 +87,11 @@ public class DirectoryDiscoverer implements ITypeDiscoverer
|
||||||
modParser = new ASMModParser(fis);
|
modParser = new ASMModParser(fis);
|
||||||
fis.close();
|
fis.close();
|
||||||
}
|
}
|
||||||
|
catch (LoaderException e)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, e, "There was a problem reading the file %s - probably this is a corrupt file", file.getPath());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Throwables.propagate(e);
|
Throwables.propagate(e);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.zip.ZipFile;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.LoaderException;
|
||||||
import cpw.mods.fml.common.MetadataCollection;
|
import cpw.mods.fml.common.MetadataCollection;
|
||||||
import cpw.mods.fml.common.ModContainer;
|
import cpw.mods.fml.common.ModContainer;
|
||||||
import cpw.mods.fml.common.ModContainerFactory;
|
import cpw.mods.fml.common.ModContainerFactory;
|
||||||
|
@ -44,7 +45,16 @@ public class JarDiscoverer implements ITypeDiscoverer
|
||||||
Matcher match = classFile.matcher(ze.getName());
|
Matcher match = classFile.matcher(ze.getName());
|
||||||
if (match.matches())
|
if (match.matches())
|
||||||
{
|
{
|
||||||
ASMModParser modParser = new ASMModParser(jar.getInputStream(ze));
|
ASMModParser modParser;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
modParser = new ASMModParser(jar.getInputStream(ze));
|
||||||
|
}
|
||||||
|
catch (LoaderException e)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, e, "There was a problem reading the entry %s in the jar %s - probably a corrupt zip", ze.getName(), candidate.getModContainer().getPath());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
modParser.validate();
|
modParser.validate();
|
||||||
modParser.sendToTable(table, candidate);
|
modParser.sendToTable(table, candidate);
|
||||||
ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate);
|
ModContainer container = ModContainerFactory.instance().build(modParser, candidate.getModContainer(), candidate);
|
||||||
|
|
|
@ -3,6 +3,7 @@ package cpw.mods.fml.common.discovery.asm;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import net.minecraft.src.BaseMod;
|
import net.minecraft.src.BaseMod;
|
||||||
|
|
||||||
|
@ -12,6 +13,8 @@ import org.objectweb.asm.Type;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
|
import cpw.mods.fml.common.FMLLog;
|
||||||
|
import cpw.mods.fml.common.LoaderException;
|
||||||
import cpw.mods.fml.common.discovery.ASMDataTable;
|
import cpw.mods.fml.common.discovery.ASMDataTable;
|
||||||
import cpw.mods.fml.common.discovery.ModCandidate;
|
import cpw.mods.fml.common.discovery.ModCandidate;
|
||||||
|
|
||||||
|
@ -31,8 +34,16 @@ public class ASMModParser
|
||||||
|
|
||||||
public ASMModParser(InputStream stream) throws IOException
|
public ASMModParser(InputStream stream) throws IOException
|
||||||
{
|
{
|
||||||
ClassReader reader = new ClassReader(stream);
|
try
|
||||||
reader.accept(new ModClassVisitor(this), 0);
|
{
|
||||||
|
ClassReader reader = new ClassReader(stream);
|
||||||
|
reader.accept(new ModClassVisitor(this), 0);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FMLLog.log(Level.SEVERE, ex, "Unable to read a class file correctly");
|
||||||
|
throw new LoaderException(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void beginNewTypeName(String typeQName, int classVersion, String superClassQName)
|
public void beginNewTypeName(String typeQName, int classVersion, String superClassQName)
|
||||||
|
|
Loading…
Reference in a new issue