如果代码是这样的
@CompileStatic
class TestGroovy {
    void funcA() {
        try {
            def a = 1 + 1
        } catch (e) {
            println e
        }
    }
}
idea 反编译结果
    public void funcA() {
        try {
            try {
                int a = 1 + 1;
            } catch (Exception var6) {
                DefaultGroovyMethods.println(this, var6);
                Object var10000 = null;
            }
        } finally {
            ;
        }
    }
上面没问题,大概能根据反编译的代码看出原始代码。
如果在 catch 块中添加 return 语句
@CompileStatic
class TestGroovy {
    void funcA() {
        try {
            def a = 1 + 1
        } catch (e) {
            println e
            return
        }
    }
}
idea 反编译无法反编译
    public void funcA() {
        // $FF: Couldn't be decompiled
    }
使用 jd.gui 进行反编译,能正常反编译,而且变量名更友好。
  public void funcA() {
    try {
      int a = 1 + 1;
    } catch (Exception e) {
      DefaultGroovyMethods.println(this, e);
      null;
      return;
    } finally {}
  }
idea 2019.03
所以如何能让 idea 的反编译达到 jd.gui 这种效果呢
|  |      1git00ll OP 使用 jd 反编译出来的代码 return 上面一行,是不符合 java 语法的 | 
|  |      3paouke      2021-07-03 16:39:22 +08:00 via iPhone 要不,升级下 idea ? |