Skip to content

Commit

Permalink
Added invokespecialinterface and invokestaticinterface
Browse files Browse the repository at this point in the history
  • Loading branch information
jumanji144 committed Aug 26, 2022
1 parent 45b641a commit f299d24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class ParseInfo {
public String[] args;
public static final int INSTRUCTION_LINE = -1;
public static final int INSTRUCTION_INVOKEVIRTUALINTERFACE = -2;
public static final int INSTRUCTION_INVOKESTATICINTERFACE = -3;
public static final int INSTRUCTION_INVOKESPECIALINTERFACE = -4;

public ParseInfo(String name, int opcode, String... args) {
this.name = name;
Expand Down Expand Up @@ -228,6 +230,8 @@ public static boolean has(String instruction) {
put("tableswitch", TABLESWITCH, "switch");
put("line", INSTRUCTION_LINE, "label", "const");
put("invokevirtualinterface", INSTRUCTION_INVOKEVIRTUALINTERFACE, "name", "descriptor");
put("invokestaticinterface", INSTRUCTION_INVOKESTATICINTERFACE, "name", "descriptor");
put("invokespecialinterface", INSTRUCTION_INVOKESPECIALINTERFACE, "name", "descriptor");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,27 @@ public void visitInstruction(InstructionGroup inst) throws AssemblerException {
case INVOKESTATIC:
case INVOKEINTERFACE:
case INVOKESPECIAL:
case ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE: {
case ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE:
case ParseInfo.INSTRUCTION_INVOKESTATICINTERFACE:
case ParseInfo.INSTRUCTION_INVOKESPECIALINTERFACE: {

IdentifierGroup name = (IdentifierGroup) inst.get(0);
IdentifierGroup desc = (IdentifierGroup) inst.get(1);

boolean itf = opcode == INVOKEINTERFACE
|| opcode == ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE
|| opcode == ParseInfo.INSTRUCTION_INVOKESTATICINTERFACE
|| opcode == ParseInfo.INSTRUCTION_INVOKESPECIALINTERFACE;

if(opcode == ParseInfo.INSTRUCTION_INVOKESTATICINTERFACE) opcode = INVOKESTATIC;
if(opcode == ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE) opcode = INVOKEVIRTUAL;
if(opcode == ParseInfo.INSTRUCTION_INVOKESPECIALINTERFACE) opcode = INVOKESPECIAL;

mv.visitMethodInsn(
opcode == ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE
? INVOKEVIRTUAL
: opcode,
opcode,
name,
desc,
opcode == INVOKEINTERFACE || opcode == ParseInfo.INSTRUCTION_INVOKEVIRTUALINTERFACE
itf
);
// INFO: opcode == INVOKEINTERFACE is not always correct because there are some
// INVOKEVIRTUAL instructions which have itf=true but for that static analysis is
Expand Down

0 comments on commit f299d24

Please sign in to comment.