guxingke / mini-jvm

使用 JDK8 实现 JVM(Java Virtual Machine)

Home Page:https://jvm.guxingke.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

IfICmpEqInst.execute Integer equal issue

raoshaoquan opened this issue · comments

`public class IfICmpEqInst implements Instruction {
public final int offset;

public IfICmpEqInst(int offset) {
this.offset = offset;
}

@OverRide
public int offset() {
return 3;
}

@OverRide
public void execute(Frame frame) {
Integer val2= frame.popInt();
Integer val1= frame.popInt();
### if (val1 == val2) { //Objects.equals(val1, val2)
frame.nextPc = frame.thread.getPc() + offset;
}
}
}
`

yes, you are right at if valx type is reference , but in this case, the valx always int. not a Integer ref .

I see

sorry , you are right, i meet a corner case . 😂