File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Instantiating Local Classes

 
Vishnu Khera
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


The above code is from a book. I'm unable to understand what the author means by " In the non-static method, the reference to the instance of the enclosing context is passed implicitly in the constructor call of the non-static local class at (6). "
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Inner Story (<= click) .

download a good decompiler (for example jad) , and open the inner classes. surprisingly you can find a different default constructor !
 
Vishnu Khera
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman I looove campfire stories Liked the Pass-by-value Please story

Thanks for sharing the link and for your response

Downloaded JD-GIU (a java decompiler) and decompiled the following code :


FOUND THIS :



Now my question is - is there some specification about how class files would be named once we define inner classes - like it shows $ as a seperator; and $1 as a seperator for local classes?
 
Mala Gupta
Author
Ranch Hand
Posts: 281
9
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vishnu,

Now my question is - is there some specification about how class files would be named once we define inner classes - like it shows $ as a seperator; and $1 as a seperator for local classes?


$ followed by an integer is used for local classes because you can declare multiple local classes with the same name, in different methods. The following code adds a definition of local class 'InsideMethod' in 'method2()':



When you compile the above class, the Java compiler will generate the following class files for the local inner classes 'InsideMethod' defined in 'method()' and 'method2()':

Outer$1InsideMethod.class
Outer$2InsideMethod.class

With respect,
Mala
 
Vishnu Khera
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response Mala
 
Abdullah mohammad
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seetharaman Venkatasamy wrote:Inner Story (<= click) .

download a good decompiler (for example jad) , and open the inner classes. surprisingly you can find a different default constructor !
 
Vishnu Khera
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic