author | vromero |
Thu, 19 Dec 2013 21:58:50 +0000 | |
changeset 22166 | adc980c0dbcc |
permissions | -rw-r--r-- |
22166
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
1 |
/* |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
3 |
* @bug 8030218 |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
4 |
* @summary javac, compile time error isn't shown when final static field is not assigned, follow-up |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
5 |
* @compile/fail/ref=CompileTimeErrorForNonAssignedStaticFieldTest.out -XDrawDiagnostics CompileTimeErrorForNonAssignedStaticFieldTest.java |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
6 |
*/ |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
7 |
|
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
8 |
public class CompileTimeErrorForNonAssignedStaticFieldTest { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
9 |
private final static int i; |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
10 |
|
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
11 |
public CompileTimeErrorForNonAssignedStaticFieldTest() |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
12 |
throws InstantiationException { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
13 |
throw new InstantiationException("Can't instantiate"); |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
14 |
} |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
15 |
|
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
16 |
static class Inner { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
17 |
private final int j; |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
18 |
public Inner(int x) |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
19 |
throws InstantiationException { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
20 |
if (x == 0) { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
21 |
throw new InstantiationException("Can't instantiate"); |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
22 |
} else { |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
23 |
j = 1; |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
24 |
} |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
25 |
System.out.println(j); |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
26 |
} |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
27 |
} |
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
28 |
|
adc980c0dbcc
8030218: javac, compile time error isn't shown when final static field is not assigned, follow-up
vromero
parents:
diff
changeset
|
29 |
} |