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

what is "myclass$1.class"?  RSS feed

 
glen li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,
After running my application, there are a lot of these type of files generated in the same directory of the application: myclass$1.class, myclass$2.class, etc. Anyone had the same experience before? pls tell me what they are and how to deal with it? Thanks!

glen
 
Ben Wood
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think Java uses the $ character to denote an inner class, so for example if you have a class called A which contains an inner class called B you would end up with A.class and A$B.class when compiled. Do you have any inner classes in your application?
 
Henrique Sousa
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Glen,
These are anonymous classes. You see, every compiled class must have a bytecode file, right? Well, anonymous classes are named as <ParentClass>$<Number>.class. Just so you identify the anonymous classes in your code, they shall look like this:



After compiling this, you will have 3 files:
ParentClass.class
ParentClass$MyInterface.class <-- The inner interface
ParentClass$1.class <-- The anonymous class

Hope it helped. Regards,
 
glen li
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnak you all guys. From your reply I figured it maybe the GUI components I used, there are some inner classes there. I really appreaciate your help.

glen
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!