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