Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is significance of final AB this$0;

 
gauravkv gupta
Greenhorn
Posts: 21
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4549
8
Java Netbeans IDE Scala
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic