In the following code it is clear that baa is always false. Will the hotspot compiler spot this and remove the isBaa() method call and contained code?
public class Foo() {
public final boolean baa = false;
public isBaa() {
return baa;
}
}
Usage like this
static final Foo foo = new Foo();
public m() {
if (foo.isBaa()) {
// code here...
}
}
I'd like to know if this code compares to adding
static final Foo foo = new Foo();
static final BAA = foo.isBaa();
and checking with
if (BAA) ...
Interested in runtime speed after hotspot has done its thing. Is there anyway to actually see what the result of hotspot compilation is? Or do we have to infer from the implementation details of the hotspot compiler being used.
The use case is to back isDebugEnabled() by a final variable in very performance sensitive code. So I'm interested in whether the method call itself is optimized out.