Name: skT88420 Date: 05/17/99
The javac compiler produces class files for anonymous inner
classes even when those classes are contained in blocks of
dead code. Since these classes can never be instantiated,
they only consume space which is a big concern for applet
developers. Consider the following class:
// DeadClass.java
class DeadClass {
static final boolean ALIVE = false;
void someMethod() {
if (ALIVE) {
// This block is dead since ALIVE evaluates to the
// constant "false" at compile time.
Object o = new Object() {
void anotherMethod() { }
};
}
}
}
Compiling the above source file creates the files "DeadClass.class"
and "DeadClass$1.class". However, a quick inspection of the byte
codes using "javap -c DeadClass" reveals that DeadClass$1 is never
instantiated. The compiler should remove this class as part of
its dead code elimination.
(Review ID: 83164)
======================================================================