author | mcimadamore |
Wed, 26 Oct 2016 15:41:25 +0100 | |
changeset 41856 | 13a056e8f16e |
parent 25308 | 190cac01c316 |
permissions | -rw-r--r-- |
10 | 1 |
/* |
25308
190cac01c316
8044236: create .out files for DefiniteAssignment tests in tools/javac dir
sogoel
parents:
5520
diff
changeset
|
2 |
* @test /nodynamiccopyright/ |
10 | 3 |
* @bug 4240487 |
4 |
* @summary Verify that we keep track of init/uninits in Try statement |
|
5 |
* without finalizer. |
|
6 |
* |
|
25308
190cac01c316
8044236: create .out files for DefiniteAssignment tests in tools/javac dir
sogoel
parents:
5520
diff
changeset
|
7 |
* @compile/fail/ref=DefAssignAfterTry1.out -XDrawDiagnostics DefAssignAfterTry1.java |
10 | 8 |
*/ |
9 |
||
10 |
class E1 extends Exception {} |
|
11 |
class E2 extends Exception {} |
|
12 |
||
13 |
public class DefAssignAfterTry1 { |
|
14 |
public static void main(String argv[]) { |
|
15 |
boolean t = true; |
|
16 |
E1 se1 = new E1(); |
|
17 |
E2 se2 = new E2(); |
|
18 |
int i; |
|
19 |
try { |
|
20 |
if (t) { |
|
21 |
throw se1; |
|
22 |
} |
|
23 |
} catch (E1 e) { |
|
24 |
i = 0; |
|
25 |
} |
|
26 |
// the following line should result in a compile-time error |
|
27 |
// variable i may not have been initialized |
|
28 |
System.out.println(i); |
|
29 |
System.out.println("Error : there should be compile-time errors"); |
|
30 |
} |
|
31 |
} |