Allow pool to be dynamically rebuilt

This commit is contained in:
Adam
2015-05-09 17:00:30 -04:00
parent 0d21d49d2d
commit 4af719032d
45 changed files with 597 additions and 333 deletions

View File

@@ -8,8 +8,9 @@ import java.io.IOException;
public class InterfaceMethod extends PoolEntry
{
private int classIndex;
private int nameAndTypeIndex;
private int classIndex, natIndex;
private Class clazz;
private NameAndType nat;
public InterfaceMethod(ConstantPool pool) throws IOException
{
@@ -18,23 +19,47 @@ public class InterfaceMethod extends PoolEntry
DataInputStream is = pool.getClassFile().getStream();
classIndex = is.readUnsignedShort();
nameAndTypeIndex = is.readUnsignedShort();
natIndex = is.readUnsignedShort();
}
@Override
public void resolve()
{
clazz = this.getPool().getClass(classIndex);
nat = this.getPool().getNameAndType(natIndex);
}
@Override
public void prime()
{
classIndex = this.getPool().make(clazz);
natIndex = this.getPool().make(nat);
}
@Override
public boolean equals(Object other)
{
if (!(other instanceof InterfaceMethod))
return false;
InterfaceMethod i = (InterfaceMethod) other;
return clazz.equals(i.clazz) && nat.equals(i.nat);
}
public Class getClassEntry()
{
return (Class) this.getPool().getEntry(classIndex);
return clazz;
}
public NameAndType getNameAndType()
{
return (NameAndType) this.getPool().getEntry(nameAndTypeIndex);
return nat;
}
@Override
public void write(DataOutputStream out) throws IOException
{
out.writeShort(classIndex);
out.writeShort(nameAndTypeIndex);
out.writeShort(natIndex);
}
}