loop to deliberately cause program to crash?
Code:
class GamePlayer {
int doSomeMove() {
// for loop put in here deliberately to cause timeout
for (;;) {
}
return 5;
}
}
i'm trying to test my system with timeouts and stuff, by doing malicious coding on purpose. but the above doesn't work anyway as it says
Test.java:40: unreachable statement
return 5;
^
1 error
how could i make this work to test stuff?
Re: loop to deliberately cause program to crash?
Make a boolean that's true then have a while loop with the boolean as its parameter.
Re: loop to deliberately cause program to crash?
Quote:
Originally Posted by Steve_F
Make a boolean that's true then have a while loop with the boolean as its parameter.
Let it be a class member, and make sure it's neither const nor final