Java class name containing dollar sign fails to compile if an inner class is present

You have a name conflict because you defined a top-level class A$B having the same name as the generated name for a static inner class B of class A. Since you have both, the compiler can’t resolve the conflict.

The JLS says:

The $ character should be used only in mechanically generated source code or, rarely, to access pre-existing names on legacy systems.

Since you decided not to respect that rule, you got bitten by javac. I would just rename A$B to something else.

Leave a Comment