Java反编译 [英] java decompilation

查看:176
本文介绍了Java反编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用java反编译器(http://java.decompiler.free.fr/)反编译特定的jar时,我得到了一些奇怪的代码,无法识别出什么。有人能帮我吗?代码类似于:

When decompiling a specific jar using java decompiler (http://java.decompiler.free.fr/) I got some strange code I cannot identify what is. can someone help me? the code is something like:

Foo.access$004(Foo.this);

或此

Bar.access$006(Bar.this);

否则

Baz.access$102(Baz.this, true)

这些方法是什么 access $ 004 access $ 006 access $ 102

推荐答案

创建类似这样的合成方法来支持访问内部类的私有方法。由于内部类不是初始jvm版本的一部分,因此访问修饰符无法真正处理这种情况。解决方案是创建其他包可见的方法,这些方法委派给私有实现。

Synthetic methods like this get created to support acessing private methods of inner classes. Since inner classes were not part of the initial jvm version, the access modifiers could not really handle this case. The solution was to create additional package-visible methods that delegate to the private implementation.

public class Example {
    private static class Inner {
         private void innerMethod() { ... }
    }

    public void test() {
        Inner inner = ...
        inner.innerMethod():
    }
}

编译将创建 Inner 类的新方法,如下所示:

The compile would create a new method of the Inner class like this:

static void access$000(Inner inner) {
    inner.innerMethod();
}

并替换 test 这样的方法:

Inner.access$000(inner);

静态 access $ 000 可见,并且因此可以从外部类访问,并且位于同一 Inner 类内部,因此可以将其委派给私有的 innerMethod

The static access$000 is package visible and so accessible from the outer class, and being inside the same Inner class it can delegate to the private innerMethod.

这篇关于Java反编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆