0

So this question is fairly simple, and I feel like it's kind of an idiot question.

When I run my program, many duplicates of classes are being generated. Specifically JFrame classes. If I look in my build/packagename/classes/ directory, I'll see JFrameClassName.class, followed by several class duplicates labelled JFrameClassName$1.class, JFrameClassName$2.class, JFrameClassName$3.class etc.

The main JFrame classes have the correct file size. Their duplicates only seem to be 1KB, but they aren't empty. I'm not asking for a specific solution here, I would just like to know what the possible problems that could be causing this are. If anyone could help I would greatly appreciate it. Thanks

Blackvein
  • 558
  • 4
  • 10
  • 23
  • Do you have embedded classes, interfaces or enums in your JFrame Class? – Jyro117 Feb 09 '12 at 16:40
  • possible duplicate of [Multiple .class files generated for a class?](http://stackoverflow.com/questions/1031962/multiple-class-files-generated-for-a-class) – Brian Roach Feb 09 '12 at 16:41

2 Answers2

5

They're anonymous inner classes.

More precisely, you'll see one main class file, as well as a subsidiary file for each anonymous inner class.

pauljwilliams
  • 19,079
  • 3
  • 51
  • 79
1

This is a classes from main class, for example:

package test;

public abstract class Test {

    abstract void getA();

    private class SubTest {

        // Inner class
        Test test = new Test() {
            @Override
            void getA() {
            }
        };
    }
}

In the main class Test there are also SubTest and

new Test() {
    @Override
    void getA() {}
};

They all saves in different files.

kornero
  • 1,109
  • 8
  • 11