Does Java Compiler / VM optimize temp variables which are for inspecting in debugger

51 Views Asked by At

Here are two versions of the same method.

public static int getSomeValue() {
return getValueX() * getValueY() - getValueZ();
}
public static int getSomeValue() {
int jX = getValueX();
int jY = getValueY();
int jZ = getValueZ();
int jRet = jX * jY - jZ;
return jRet;
}

The second method is great for debugging, one can put a break point on say "return jRet" and inspect the three values.

Will the Compiler / JVM optimize these variables out?

0

There are 0 best solutions below