• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Please Clarify Code( "final MainWindow this$0;" and "this$0 = MainWindow.this; super();")

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was going through this code and kind of need help to understand a part of it.



What effect does this statement have on the program especially "final MainWindow this$0;" and "this$0 = MainWindow.this; super();". From What I understand super() should be the first statement of the class. So I think it is useless to have such code in a program. Kindly help me clarify this.

 
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did you decompile this code? Because the this$0 is a reference to the instance of the enclosing class, and usually it's implicitly added by the compiler. I've never seen anyone add it manually.
Another giveaway about you (or someone else) having decompiled it is the assignment to this field before the call to super(); that's not allowed, and won't compile again.
 
Ranch Hand
Posts: 227
Eclipse IDE Spring Java
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every non-static inner class instance, even that of an anonymous one, has a reference to an outer class instance, in context of which it is instantiated. Compiler provides it without us needing to make it explicit in code. When we decompile the code, some of this compiler "magic" also gets decompiled and printed in the output.

You can safely delete the lines 8 and 12 in your code below:

 
Abdulazeez Hassan
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the clarification. I understand it perfectly now. Rob thanks for the answer, I didn't decompile the code it is an assignment given to me to read trough. May be my tutor did. Thanks anyway.
 
Rob Spoor
Sheriff
Posts: 22701
129
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
Marshal
Posts: 76856
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch

I have edited your post because the long lines make it difficult to read. It is a good idea to restrict line length to 120 cahracters. That way nobody has to scroll right and left.
 
Your mind is under my control .... your will is now mine .... read this tiny ad
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic