• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 22783
131
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: 22783
131
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: 79178
377
  • 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.
 
It's a tiny ad only because the water is so cold.
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic