我试图在反编译一些
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.
解决方法
goto bytecode instruction(是的,它实际上被称为“goto”)用于实现break和其他结构.
goto本身的规范仅将目标限制在与goto指令相同的方法中.
4.10. Verification of class Files中定义了许多其他约束,特别是Checking Code,其中描述了如何验证方法的实际字节码.
我怀疑你不能用goto对局部变量和操作数堆栈产生不一致的解释,例如要求目标指令与源指令兼容,但是我的实际规范是用Prolog写的,我会感激的如果有人得到了确保这一点的相关点.