Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 奇怪的continue关键字用法_Java_Loops_Try Catch_Continue - Fatal编程技术网

Java 奇怪的continue关键字用法

Java 奇怪的continue关键字用法,java,loops,try-catch,continue,Java,Loops,Try Catch,Continue,我正在复习一些Java代码,现在已经第二次遇到这种事情了 while (true) try { //some simple statements continue; try { Thread.sleep(1000L); } catch (InterruptedException e) { SamsetUtils.LogError(this.logger, e.getMessage() + ".29"); }

我正在复习一些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语句总是被执行,并且总是立即开始另一个迭代。首先,我将一个类似的情况标记为bug,但这一次引起了我的怀疑,因为这都是商业上使用的假定工作代码的一部分。这段代码在某种程度上起作用了吗

类似情况如下:

 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
  }

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

该代码段甚至不应该编译,更不用说正常工作了——Java编译器应该给出一个关于“unreachable statement”的错误。你确定你看到的就是这个密码吗?是的。是的,我直接从文件中复制粘贴了一些语句,为了清晰起见,我在标记的地方编辑了一些语句。由于缺少库的问题,现在无法尝试编译它,但是代码实际上是从一个jar文件中反编译的,听起来好像反编译器被搞糊涂了。