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=DefAssignAfterTry2.out -XDrawDiagnostics DefAssignAfterTry2.java 8 */ 9 10class E1 extends Exception {} 11class E2 extends Exception {} 12 13public 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} 36