I have the following Java code:
public class App{
public int sum(){
return (1 + 2) + (3 + 4);
}
}
After compiling it using javac App.java and inspecting the bytecode with javap -v App, I noticed that the method sum is optimized:
0: bipush 10
2: ireturn
It seems that javac performed constant folding. Is there a way to disable this behavior by default? I'm aiming to obtain verbose bytecode, resembling the following:
iconst_1
iconst_2
iadd
iconst_3
iconst_4
iadd
iadd
ireturn
Any insights or suggestions on how to achieve this would be greatly appreciated.