Original Post
I get some weird results in my java code, basically what happens is that I set a flag in one of my classes to true outside a try catch statement and then when I read the flag within the try catch statement it returns both true and false :/ Basically the code looks something like this:
// in VertexBuffer.java
public void lock() {
locked = true;
// do more stuff here...
}
public void isLocked() {
return locked;
}
// in Main.java
public void someMethod() {
terrain.patch[0][0].getVertexBuffer().lock();
try {
if( terrain.getPatch(0, 0).getVertexBuffer().isLocked() == true ) { // omg! JVM knows it's true!
System.out.println("Hello World!");
}
if( terrain.getPatch(0, 0).getVertexBuffer().isLocked() == false ) { // omg! WTH? JVM thinks this is also true
System.out.println("Hello World, Again!");
}
// more stuff here...
} catch(Exception e) {
// do appropiate stuff
}
}
Output:
Hello World!
Hello World, Again!
What happens is that both if statements succeed!!! Now how in the hell is that possible??