What is the meaning of “static synthetic”?

前端 未结 3 535
梦毁少年i
梦毁少年i 2020-12-03 06:45

I am looking at some disassembled code obtained from Java bytecode. I see some declaration as follows:

.method static synthetic access$0()Lcom/package/Sample         


        
3条回答
  •  失恋的感觉
    2020-12-03 07:50

    In the java language, inner classes can access private members of their enclosing class. However, in Java bytecode, the concept of inner classes does not exist, and the private members are not accessible. To work around this, the compiler creates synthetic accessor methods in the outer class. I believe that is what you are seeing here. access$0 is simply the name of the method. I'm not sure what, if anything the synthetic does. It may just hide the method from other compilers to ensure encapsulation.

提交回复
热议问题