public abstract class BS {
/** The local host default. */
public static final InetAddress LOCALHOST;
static {
InetAddress localhost = null;
try {
localhost = InetAddress.getLocalHost();
}
catch ( UnknownHostException ex ) {
System.err.println("Failed to retrieve local host");
}
LOCALHOST = localhost;
}
}
If compiled with javac BS.java, no problem is reported.
If compiled a BSS extending BS, as javac BSS.java,
I get (reported for BS.java, not BSS):
Blank final variable 'LOCALHOST' may not have been initialized.
It must be assigned a value in an initializer, or in every
constructor.
static {
Even if the error was justified, the error should be reported
no matter what source I compile - and yes, I deleted *all* class
files. Worse, if I compile BS first, BSS afterwards, no compile
error is reported. Is this Sun BS? Or some Linux JDK problem?
b.