blob: d4bd9bf0d9b6fa9c022aba6c4813c73693ea5e48 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import org.aspectj.testing.Tester;
public class InitializationOrder {
public static void main (String[] args) {
C c = new C();
Tester.check(null != c.s, "null == c.s");
Sub s = new Sub();
Tester.check("ok" == s.o, "\"ok\" == s.o");
Tester.check(null == s.p, "null == s.p");
}
}
class C {
public String s = null;
C(String s) { this.s = s; }
C() { this("uh oh"); }
}
class S {
public Object p;
S(Object p) {this.p = p;}
}
class Sub extends S {
Sub() {
super(null); // if (o), then C E illegal use of uninitialized value
o = "ok";
}
Object o;
}
|