Java break/label语句可以在字节码混淆中充当"goto"吗?

Kha*_*oud 10 java bytecode

我试图在反编译后对一些Java .class文件进行反混淆处理,而且我遇到了代码的一部分,它以一种我认为不能使用标签的方式使用标签.我不知道这是否是反编译器误解标签的错误,或者代码是否故意以这种方式混淆.换句话说,可以在Java字节码中以这种方式使用标签吗?

请注意,标签出现在相关的break语句之后,而不是之前.它几乎似乎是使用它们作为goto,而不是用于退出循环的标签.根本没有循环,所以我对它们应该如何在这里使用感到困惑.

这里发生了什么?我在评论中标记了3个标签(###)

if (i != 96)
  {
    if ((i ^ 0xFFFFFFFF) != -98)
    {
      if (i == 98)
        break label417;  // ### Here are the three breaks... The relevant labels appear later in the code
      if (i != 99)
        break label540;
      if (!bool)
        break label461;
    }
  }
  else
  {
    if (localwb == this.localWB5)
    {
      if (this.localWB4 != null) {
          this.localWB4.a((byte)-92, this);
        if (!bool);
      }
      else
      {
          this.localWB6.a((byte)-9, this);
      }
      return true;
    }
    if (localwb == this.localWB4)
    {
        this.localWB6.a((byte)-59, this);
      return true;
    }
    if (this.localWB3 != localwb)
      break label540;
      this.localWB2.a((byte)-38, this);
    return true;
  }
  if (this.localWB6 == localwb)
  {
    if (this.localWB4 != null) {
        this.localWB4.a((byte)-122, this);
      if (!bool);
    }
    else {
        this.localWB5.a((byte)-63, this);
    }
    return true;
  }
  if (this.localWB4 == localwb)
  {
    this.localWB5.a((byte)-22, this);
    return true;
  }
  if ((this.localWB2 == localwb) && (this.localWB3.M))
  {
    this.localWB3.a((byte)-84, this);
    return true;
    label417:  //  ### The first label.  Note how this next if-statement has inaccessible code... if the above if-statement is true, it would have already returned true;  However, the label appears after the return statement, almost as if the label is being used as a goto.
    if (localwb == this.localWB2)
    {
        this.localWB6.a((byte)-86, this);
      return true;
    }
    if (this.localWB3 == localwb)
    {
      this.localWB5.a((byte)-31, this);
      return true;
      label461:  //  ###  The second label
      if ((this.localWB6 == localwb) || (this.localWB4 == localwb))
      {
          this.localWB2.a((byte)-60, this);
        return true;
      }
      if (localwb == this.localWB5)
      {
        if (this.localWB3.M)
        {
          this.localWB3.a((byte)-44, this);
          if (!bool);
        }
        else {
            this.localWB2.a((byte)-9, this);
        }
        return true;
      }
    }
  }
  label540:  //  ###  The final label.
Run Code Online (Sandbox Code Playgroud)

Joa*_*uer 5

goto字节码指令(是的,它实际上是所谓的"GOTO")被用来实现break和其他结构.

goto自身的规范限制目标与goto指令在同一方法内.

4.10class中定义了许多其他约束.验证文件,特别是在检查代码中,它描述了如何验证方法的实际字节码.

怀疑你不能对局部变量和操作数堆栈产生不一致的解释goto,例如要求目标指令与源指令兼容,但是我的实际规范是用Prolog编写的,我要感谢任何人都得到了确保这一点的相关观点.