aspose file tools*
The moose likes Java in General and the fly likes what is significance of final AB this$0; Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "what is significance of final AB this$0;" Watch "what is significance of final AB this$0;" New topic
Author

what is significance of final AB this$0;

gauravkv gupta
Greenhorn

Joined: Feb 18, 2012
Posts: 21
source code:


using the javap tool, i got the following, but i dont understand the purpose of adding these statement by compiler. please explain the usefulness of added code by compiler.
Compiled from "AB.java"

what is significance of final AB this$0;

[Added code tags]
Alexei Kaigorodov
Greenhorn

Joined: Feb 24, 2008
Posts: 17
means reference to an instance of enclosing class AB. This reference is required to access fields amd methods of AB from within nested class B.
Matthew Brown
Bartender

Joined: Apr 06, 2010
Posts: 4422
    
    8

You know that an inner class can access member variables and methods in the enclosing object, right? Well, this is how the compiler makes that possible. It passes a reference to the enclosing object into the inner class, via a constructor that it generates.

If you modified your original code to call a method in the enclosing object, you'll find that in the decompiled version the call is prefixed with this this$0 reference.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: what is significance of final AB this$0;