Name: diC59631 Date: 02/24/98
To repro:
1 compile both of S.java and C.java
2 run C#main ; "foo96" will be printed as expected
3 change a value of jj from 6 to 5;
4 re-compile only S.java
5 and run
expected : "foo95" printed
actual: "foo96" printed
"new S().ii" is NOT a constant expression(JLS15.27).
Plus S#jj is NOT a constant field(JLS13.4.8,12.4.1) since it's not
"static".
However javac seems to treat it as if it's a constant field or
expression.
// S.java
class S {
static final String x = "foo";
static final int ii = 9;
final int jj = 6;
}
// C.java
public class C extends S {
static public void main(String []args) {
C c = new C();
c.doit();
}
void doit() {
String s = new S().x; // x is constant or not?
int b = new S().ii; // ii is constant or not?
int x = new S().jj; // <----------should NOT a constant
System.out.println(s + b + x);
}
}
(Review ID: 25522)
======================================================================
- relates to
-
JDK-4423705 JCK1.3a: two compiler tests fail
- Closed