2

我正在审查一些 Java 代码,现在已经第二次遇到这种事情了。

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

据我了解,关键代码总是会被省略,因为 continue 语句总是会被执行,并且总是会立即开始另一个迭代。首先,我将类似的情况标记为错误,但这次它引起了我的怀疑,因为它都是商业使用的所谓工作代码的一部分。这个片段是否以某种我不知道的方式工作?

这里的情况类似:

 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
  }
4

1 回答 1

0

这些片段来自反编译的代码,确实是反编译器弄糊涂了。我用另一个检查了它,它产生了不同的结果,虽然也很疯狂。感谢所有的帮助。

于 2013-09-04T13:17:03.883 回答