0

I have java class with name MyClass and inside I am adding new Object. When look at the the jar by winzip I saw the duplicated class as below.

MyClass$1.class
MyClass$2.class 

and so on.

What does it mean? Is it a problem as when I tried to open that jar file with decompiler it gives the error below

An unhandled exception occured. Press "Abort" to terminate the program, "Retry" to exit the program normally and "Ignore" to try to continue.

Thanks in advance.

dev dev
  • 61
  • 1
  • 7
  • `foo$something` is a [synthetic class](http://stackoverflow.com/questions/399546/synthetic-class-in-java). – Salem Jan 11 '17 at 16:58

1 Answers1

0

The original version of Java didn't have nested classes. When they were added, they were implemented as syntactic sugar in the compiler, with the classes compiled to seperate classfiles under the hood. The names use $. So MyClass$1 is an anonymous class that is contained within MyClass.

As for why your decompiler crashed, it is probably a bad decompiler. There's a lot of modern decompiles out there you can use. You could also try a tool like BytecodeViewer or Helios, which bundle together a number of different decompilers with a convenient GUI.

Antimony
  • 37,781
  • 10
  • 100
  • 107