Reputation: 61
Okay, so recently I decompiled some code I had written years ago. So, the decompiler I use does not decompile the anonymous classes, since the Java compiler compiled them as separate classes.
So, I have a file called TitleScreen, and other files following with TitleScreen$1, TitleScreen$2. Simple. But....why the numbers? The class isn't named with an int, that's impossible. How would these be structured? Do I just give them a random name like optionsClick(), worldsClick()?
Thanks!
Upvotes: 2
Views: 132
Reputation: 15729
The compiler is more powerful than us mere programmers and can name classes with that funny syntax. Perhaps it does it that way cause it knows it is "safe": no user defined class (see comments below) is likely to have that name.
As for what you should name the decompiled classes, I'd suggest TitleScreen.Anon1, TitleScreen.Anon2 if you make them inner classes, or TitleScreen_Anon1 if their own classes. That way you have some reference back to the original code if needed.
Upvotes: 1
Reputation: 160261
Those are the names the Java compiler generates for anonymous classes.
You can give them whatever name you want.
Upvotes: 3