-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.1.4
-
ppc
-
solaris_2.6
The Java Language Specification(Gosling,Joy&Steele) page 146 says that
a final field can only be initialized during the declaration time.
"Any attempt to assign to a final field results in a compile-time error".
But the following code compiles fine with sun javac
public abstract class Font {
public static final int PLAIN = java.awt.Font.PLAIN;
public static final int BOLD = java.awt.Font.BOLD;
public static final int ITALIC = java.awt.Font.ITALIC;
public final String name;
public final int style;
public final int size;
public static void init() {
if (BitmapFont.initialize() != 0) {
// System.err.println("Bitmap fonts loaded.");
}
}
public Font(String name, int style, int size, int ops) {
this.name = name;
this.style = style;
this.size = size;
this.fontOps = ops;
}
:
:
}
This code does not compile with the Symantec java compiler.
The Java Programming Language (Arnold & Gosling) page 111, however,
specifies that it's ok to have the blank final declaration and initialize
the final field in the constructor later.
a final field can only be initialized during the declaration time.
"Any attempt to assign to a final field results in a compile-time error".
But the following code compiles fine with sun javac
public abstract class Font {
public static final int PLAIN = java.awt.Font.PLAIN;
public static final int BOLD = java.awt.Font.BOLD;
public static final int ITALIC = java.awt.Font.ITALIC;
public final String name;
public final int style;
public final int size;
public static void init() {
if (BitmapFont.initialize() != 0) {
// System.err.println("Bitmap fonts loaded.");
}
}
public Font(String name, int style, int size, int ops) {
this.name = name;
this.style = style;
this.size = size;
this.fontOps = ops;
}
:
:
}
This code does not compile with the Symantec java compiler.
The Java Programming Language (Arnold & Gosling) page 111, however,
specifies that it's ok to have the blank final declaration and initialize
the final field in the constructor later.