author | sogoel |
Fri, 05 Sep 2014 16:43:00 -0700 | |
changeset 26528 | a1a7ad15183e |
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=DefAssignAfterTry2.out -XDrawDiagnostics DefAssignAfterTry2.java |
10 | 8 |
*/ |
9 |
||
10 |
class E1 extends Exception {} |
|
11 |
class E2 extends Exception {} |
|
12 |
||
13 |
public class DefAssignAfterTry2 { |
|
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 |
i = 0; |
|
22 |
throw se1; |
|
23 |
} else { |
|
24 |
throw se2; |
|
25 |
} |
|
26 |
} catch (E1 e) { |
|
27 |
} catch (E2 e) { |
|
28 |
i = 0; |
|
29 |
} |
|
30 |
// the following line should result in a compile-time error |
|
31 |
// variable i may not have been initialized |
|
32 |
System.out.println(i); |
|
33 |
System.out.println("Error : there should be compile-time errors"); |
|
34 |
} |
|
35 |
} |