You can't trust decompiled Java code.
Internally, Java bytecode treats booleans as integers. You can compile this class:
class Test {
public void foo() {
boolean myBoolean = false;
}
public void bar() {
int myInt = 0;
}
}
And then examine the javap -c Test
output:
public void foo();
Code:
0: iconst_0
1: istore_1
2: return
public void bar();
Code:
0: iconst_0
1: istore_1
2: return
As you can see, the int
and boolean
become the exact same code.
A decompiler will try its best to reconstruct valid source code from the stack based bytecode, but it's a hard problem even for unoptimized code with debug info, so it doesn't always get it right.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…