Search code examples
javadecompiling

What does it mean when you have a variable like access$002 in Java?


I have a java jar I have decompiled with permission of the original developer that we are to use until they can get us a copy of the source code. I have run into a member of a class that looks like the following:

Classname.access$002(Param1, Param2);

Classname is correct, but the access$002 does not look right (there are a few others like this except with the names access$204 and with other numbers appended to the end), and I am wondering if this means anything in Java or if it is because the decompile operation was incomplete.

I am using JD-GUI to decompile the classes.

It is also worth mentioning that there are no methods with the same signature as the access$002 method does, at least in the class Classname.


Solution

  • The access$XXX methods are calls from inner non-static classes to members of the nesting class.

    public class DummyDummy {
    
    private int x = 0;
    private Inner i = new Inner();
    private int foo(int a, int b) {
        return a+b+x;
    }
    
    private class Inner {
        void doIt() {
            System.out.println(
             // Here, DummyDummy.access$0(DummyDummy, int, int) is called 
             // which calls DummyDummy.foo(int, int)
                 foo(1,2)                 );
        }
    }
    
    public static void main(String[] args) {
        new DummyDummy().i.doIt();
    }
    
    }