PDA

Click to See Complete Forum and Search --> : loop to deliberately cause program to crash?


Pouncer
Jul 18th, 2008, 04:05 AM
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?

Steve_F
Jul 22nd, 2008, 09:29 AM
Make a boolean that's true then have a while loop with the boolean as its parameter.

ComputerJy
Jul 22nd, 2008, 11:39 AM
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