Search code examples
javadecompiling

Problem interpreting the resulting code of a decompiled java class: MyType.access$102


I'm trying to slightly extend an undocumented class in a third-party framework we're using. I decompiled the .class file with jd-gui and see an inner class defined like this:

private class DeactivateAction extends AbstractAction {
    public DeactivateAction() {
        super("Deactivate");
    }

    public void actionPerformed(ActionEvent paramActionEvent) {
        if (MyContainingType.this.someBoolean) {
            MyContainingType.access$102(MyContainingType.this, false);
            MyContainingType.this.add(MyContainingType.this.interceptor);
        }
    }
}

I am not sure how to interpret the "access$102" line here. MyContainingType extends javax.swing.JLayeredPane. This doesn't compile for me, so how can I interpret this and convert it correctly in my extended class?


Solution

  • That is a synthetic accessor.

    Even inner classes don't really have access to their enclosing class's private members. The compiler "synthesizes" default (package) access methods to allow inner classes to work with private fields of the enclosing class.

    You should be able to look at the enclosing class to figure out what access$102 is doing.

    The javap tool, with the -c option can be very useful too.