Since a double value takes two slots (on the operand stack, in the local variable table, etc.), the local variable table is as follows:
LocalVariableTable:
Start Length Slot Name Signature
0 23 0 this Lde/wwu/pi/muggl/services/SimpleService;
0 23 1 d1 D
0 23 3 d2 D
11 12 5 se Lde/wwu/pi/muggl/services/entities/SimpleEntity;
Notice that d2 is at index 3, not at 2 (even though it is the second method argument...).
However, the Load instruction in Muggl does not consider that fact:
java.lang.ArrayIndexOutOfBoundsException: 3
at de.wwu.muggl.vm.classfile.structures.Method.setVariable(Method.java:770)
at de.wwu.muggl.instructions.general.Load.executeSymbolically(Load.java:192)
at de.wwu.muggl.instructions.general.Load.executeSymbolically(Load.java:111)
at de.wwu.muggl.vm.impl.symbolic.SymbolicVirtualMachine.executeInstruction(SymbolicVirtualMachine.java:455)
at de.wwu.muggl.vm.impl.jpa.JPAVirtualMachine.executeInstruction(JPAVirtualMachine.java:38)
at de.wwu.muggl.vm.VirtualMachine.executeFrame(VirtualMachine.java:503)
at de.wwu.muggl.vm.impl.symbolic.SymbolicVirtualMachine.executeFrame(SymbolicVirtualMachine.java:377)
at de.wwu.muggl.vm.impl.jpa.JPAVirtualMachine.executeFrame(JPAVirtualMachine.java:25)
at de.wwu.muggl.vm.VirtualMachine.runMainLoop(VirtualMachine.java:427)
at de.wwu.muggl.vm.impl.symbolic.SymbolicVirtualMachine.runMainLoop(SymbolicVirtualMachine.java:272)
at de.wwu.muggl.vm.VirtualMachine.run(VirtualMachine.java:239)
Last line here throws error:
public void setVariable(int index, Variable variable) {
// Initialize the array, if needed.
if (this.variables == null) {
if (this.codeAttribute == null) {
throw new IllegalStateException("The method has no code!");
}
this.variables = new Variable[getNumberOfParameters()];
}
// Set the new one.
this.variables[index] = variable;
}
The following method is given with two double parameters as input:
The Java Instructions are:
Since a double value takes two slots (on the operand stack, in the local variable table, etc.), the local variable table is as follows:
Notice that
d2
is at index3
, not at2
(even though it is the second method argument...).However, the
Load
instruction in Muggl does not consider that fact:Last line here throws error: