Some thinking about exceptions
This commit is contained in:
@@ -46,6 +46,11 @@ public class Attributes
|
||||
|
||||
load();
|
||||
}
|
||||
|
||||
public Method getMethod()
|
||||
{
|
||||
return method;
|
||||
}
|
||||
|
||||
public Attribute findType(AttributeType type)
|
||||
{
|
||||
|
||||
@@ -39,6 +39,11 @@ public class Code extends Attribute
|
||||
return maxLocals;
|
||||
}
|
||||
|
||||
public Exceptions getExceptions()
|
||||
{
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
public Instructions getInstructions()
|
||||
{
|
||||
return instructions;
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
package info.sigterm.deob.attributes.code;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
class Exception
|
||||
public class Exception
|
||||
{
|
||||
private Exceptions exceptions;
|
||||
|
||||
@@ -23,4 +25,24 @@ class Exception
|
||||
handlerPc = is.readUnsignedShort();
|
||||
catchType = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
public Exceptions getExceptions()
|
||||
{
|
||||
return exceptions;
|
||||
}
|
||||
|
||||
public int getStartPc()
|
||||
{
|
||||
return startPc;
|
||||
}
|
||||
|
||||
public int getEndPc()
|
||||
{
|
||||
return endPc;
|
||||
}
|
||||
|
||||
public int getHandlerPc()
|
||||
{
|
||||
return handlerPc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package info.sigterm.deob.attributes.code;
|
||||
|
||||
import info.sigterm.deob.attributes.Code;
|
||||
import info.sigterm.deob.execution.ObjectInstance;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
public class Exceptions
|
||||
{
|
||||
@@ -27,4 +30,20 @@ public class Exceptions
|
||||
{
|
||||
return code;
|
||||
}
|
||||
|
||||
public Collection<Exception> getHandlersForPc(int pc)
|
||||
{
|
||||
ArrayList<Exception> matches = new ArrayList<Exception>();
|
||||
|
||||
for (Exception e : exceptions)
|
||||
{
|
||||
if (pc >= e.getStartPc() && pc < e.getEndPc())
|
||||
{
|
||||
/* possible match */
|
||||
matches.add(e);
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,6 @@ public class AThrow extends Instruction
|
||||
public void execute(Frame e)
|
||||
{
|
||||
ObjectInstance exception = (ObjectInstance) e.getStack().pop();
|
||||
e.getPath().throwException(exception);
|
||||
e.getPath().throwException(this, exception);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user