-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
5.0
-
x86
-
linux
As of JDK 1.1 there is little reason to use top-level private classes; it is better to use nested classes. They cause especial problems for many Java tools (IDEs, Ant, etc.) because it is difficult to map the .class file back to a source file: you cannot do so by name alone, but must actually open the .class file and look for its source file attribute, which is much slower (and the attribute may not even be present, depending on compiler options).
I suggest a compiler warning, to be included in -Xlint or independently configurable, which would issue a warning upon encountering any top-level class other than the main public class (whose name matches the source file). Probably very easy to implement, and would help pinpoint the last remaining uses of this unfortunate language feature so they can be eliminated in actively developed Java code.
javac warnings also can be made to show up by default in the NetBeans 6.0 source editor, which will help alert developers to the problem early.
I suggest a compiler warning, to be included in -Xlint or independently configurable, which would issue a warning upon encountering any top-level class other than the main public class (whose name matches the source file). Probably very easy to implement, and would help pinpoint the last remaining uses of this unfortunate language feature so they can be eliminated in actively developed Java code.
javac warnings also can be made to show up by default in the NetBeans 6.0 source editor, which will help alert developers to the problem early.
- relates to
-
JDK-7153951 -Xlint:auxiliaryclass
- Closed