Those snippets come from decompiled code, and it was indeed the decompiler getting confused. I checked it with another one and it produced different, although also crazy, results. Thanks for all the help.
Strange continue keyword usage
Вопрос
I'm reviewing some Java code, and have run into this kind of thing a second time now.
while (true)
try
{
//some simple statements
continue;
try {
Thread.sleep(1000L);
}
catch (InterruptedException e)
{
SamsetUtils.LogError(this.logger, e.getMessage() + ".29");
}
if (!SamsetUtils.BlockingDistributorThread)
{
//some very long and critical code here
}
}
//several catch blocks follow
To my understanding, the critical code would always be omitted, since the continue statement would always be executed and would always start another iteration immediately. First I marked a similar situation as a bug, but this time it raised my suspicions, because it's all part of supposedly working code that's being used commercially. Does this snippet work somehow, in a way I'm not aware of?
Similar situation here:
while (true)
try {
//some simple statements
if (notifications != null) {
int i = 0; continue;
this.recivedNotifies.add(notifications[i].getName());
i++; if (i >= notifications.length)
{
makeCallBack();
}
} else {
Thread.sleep(2000L);
}
}
catch (Exception e) {
//catch statements
}
Решение
Не связан с StackOverflow