-
Bug
-
Resolution: Unresolved
-
P3
-
24, 25
The assertion "Throws: IllegalArgumentException — if op is not of Opcode.Kind.BRANCH" does not work as expected (see the attached test) for 72 instructions:
public static void main(String[] args) {
Opcode[] opcodeList = Arrays.stream(Opcode.values()).
filter(oc -> oc.kind() != Opcode.Kind.BRANCH).
toArray(Opcode[]::new);
for (int i = 0, j = 0; i < opcodeList.length; i++) {
Opcode opcode = opcodeList[i];
try {
ClassFile.of().build(ClassDesc.of("Cls"), clsb -> {
clsb.withMethod("mtd", MethodTypeDesc.ofDescriptor("()I"),
ClassFile.ACC_STATIC,
mb -> mb.withCode(cb -> {
Label LBL = cb.newLabel();
cb.loadConstant(0);
cb.branch(opcode, LBL);
cb.loadConstant(1);
cb.ireturn();
cb.labelBinding(LBL);
cb.loadConstant(2);
cb.ireturn();
}));
});
} catch (IllegalArgumentException e) {
continue;
}
System.out.println("%d) %s(%s) doesn't throw IllegalArgumentException as expected".
formatted(j++, opcode, opcode.kind()));
}
}
public static void main(String[] args) {
Opcode[] opcodeList = Arrays.stream(Opcode.values()).
filter(oc -> oc.kind() != Opcode.Kind.BRANCH).
toArray(Opcode[]::new);
for (int i = 0, j = 0; i < opcodeList.length; i++) {
Opcode opcode = opcodeList[i];
try {
ClassFile.of().build(ClassDesc.of("Cls"), clsb -> {
clsb.withMethod("mtd", MethodTypeDesc.ofDescriptor("()I"),
ClassFile.ACC_STATIC,
mb -> mb.withCode(cb -> {
Label LBL = cb.newLabel();
cb.loadConstant(0);
cb.branch(opcode, LBL);
cb.loadConstant(1);
cb.ireturn();
cb.labelBinding(LBL);
cb.loadConstant(2);
cb.ireturn();
}));
});
} catch (IllegalArgumentException e) {
continue;
}
System.out.println("%d) %s(%s) doesn't throw IllegalArgumentException as expected".
formatted(j++, opcode, opcode.kind()));
}
}