I want to see the bytecode of this code using javap -c.
if (3 < 5) {
}
But for some reason it doesn't show the steps. Unlike with int a; which works fine.
Any ideas how to see this in bytecode?
I want to see the bytecode of this code using javap -c.
if (3 < 5) {
}
But for some reason it doesn't show the steps. Unlike with int a; which works fine.
Any ideas how to see this in bytecode?
The Compiler is not as dumb as you think. The block you try to see in byte code is:
That means that the compiler will leave it out of the byte code completely.
Try the following:
int a = 3;
if(a < 5)
{
a = 3 + 5;
}
and you will get the following assembly instructions in your byte code:
0: iconst_3
1: istore_1
2: iload_1
3: iconst_5
4: if_icmpge 10
7: bipush 8
9: istore_1
10: return
javap -c : Print the Java Virtual Machine instructions for each of the methods in each of the specified classes. This option disassembles all methods, including private methods.
As there is nothing in your block and as the condition is always true, you may not see the byte code.