1/* 2 * @test /nodynamiccopyright/ 3 * @bug 4240487 4 * @summary Verify that we keep track of init/uninits in Try statement 5 * without finalizer. 6 * 7 * @compile/fail/ref=DefAssignAfterTry3.out -XDrawDiagnostics DefAssignAfterTry3.java 8 */ 9 10class E1 extends Exception {} 11class E2 extends Exception {} 12 13public class DefAssignAfterTry3 { 14 public static void main(String argv[]) { 15 boolean t = true; 16 E1 se1 = new E1(); 17 E2 se2 = new E2(); 18 19 int i; 20 try { 21 i = 0; 22 if (t) 23 throw se1; 24 else 25 throw se2; 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} 36