15

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.

codewario
  • 19,553
  • 20
  • 90
  • 159
  • These links may help: http://www.retrologic.com/innerclasses.doc7.html and http://stackoverflow.com/questions/6167326/java-class-name-containing-dollar-sign - the first link mentions that they may be methods created as part of internal access classes to help the JVM understand the grouping of classes that can access some member. – wkl Sep 07 '11 at 14:15
  • 1
    The technical term is synthetic accessor. – McDowell Sep 07 '11 at 21:58

1 Answers1

20

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();
}

}
king_nak
  • 11,313
  • 33
  • 58
  • It is a generated [synthetic method](http://docs.oracle.com/javase/7/docs/api/java/lang/reflect/Method.html#isSynthetic()) – Radim Mar 28 '15 at 09:36