| Author |
Instantiating Local Classes
|
Vishnu Khera
Greenhorn
Joined: Nov 29, 2008
Posts: 24
|
|
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
Joined: Jan 28, 2008
Posts: 5575
|
|
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
Joined: Nov 29, 2008
Posts: 24
|
|
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
Joined: Sep 27, 2002
Posts: 196
|
|
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
|
Author of book OCA Java SE 7 Programmer I Certification Guide from Manning
|
 |
Vishnu Khera
Greenhorn
Joined: Nov 29, 2008
Posts: 24
|
|
Thanks for your response Mala
|
 |
Abdullah mohammad
Greenhorn
Joined: Feb 22, 2013
Posts: 3
|
|
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
Joined: Nov 29, 2008
Posts: 24
|
|
|
 |
 |
|
|
subject: Instantiating Local Classes
|
|
|