Skip to main content

Inner class file

2 replies [Last post]
Joined: 2007-12-03

Does anyone know if there is any way that a Java compiler ( or any IDE ) could have generated what appears to be an inner class file without that inner class having been defined in the original source code? For example, I have a program that has a .class file called Main$ForecastSales among its files. But there is no inner class defined inside the file, which is among the files. And when I run:

javap -c -l Main$ForecastSales

The output generated starts with:

"Compiled from ""
public class Main$ForecastSales extends java.lang.Object"

I could be wrong, but this suggests that there was an inner class called ForecastSales defined, at some point in the program's development, inside

Does anyone have any other suggestions as to how the Main$ForecastSales.class file could have come to be in the program?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2004-09-22

The most common reason I've seen for a .class file existing where there is no corresponding class defined in a .java file is that I haven't cleaned out my build directory since the last time that class existed in the source file. Try deleting the build output directory (or deleting all .class files), building, and seeing if it re-appears.

Also note that enums are really classes, too, and will show up as a class extending Object.

Joined: 2007-12-03

Sincere thanks - much appreciated!