如何在反编译.class文件后解决语法错误

时间:2014-02-24 06:11:35

标签: java android exception-handling decompiling decompiler

我的问题是,当我反编译我的.class文件时,它在catch块中显示错误,反映奇怪的最终结果是我的代码。

public void f() {
    try {
        if (this.u == 0) {
            this.h();
        } else {
            this.i();
        }

    } catch (Exception var2) {
        throw var2;       // exception occur here
    }
}

3 个答案:

答案 0 :(得分:2)

将此功能写为

    public void f() throws Exception {
          try {
             if(u == 0) {
                this.h();
             } else {
                this.i();
             }

          } catch (Exception var2) {

                throw var2;       // exception occur here


       }
}

并捕获您调用此函数的异常。

答案 1 :(得分:0)

问题在于throw语句。 解决这个问题

选项1

public void f() throws Exception

使用函数声明添加throw语句。

选项2

try {
    throw var2; // exception occur here
} catch (Exception e) {
    // do something
}

抓住这个抛出异常。

答案 2 :(得分:-1)

我只是替换下面的行

throw var2;

throw new RuntimeException();

现在它正常工作,我使用“Easy To java Source Converter”反编译器进行反编译。

感谢所有人!!!