1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/tools/javac/flow/tests/TestCaseTry.java Sat Sep 14 19:04:47 2013 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* /nodynamiccopyright/ */ 1.5 + 1.6 +import java.io.BufferedReader; 1.7 +import java.io.FileReader; 1.8 + 1.9 +public class TestCaseTry { 1.10 + 1.11 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=8) 1.12 + @AliveRange(varName="o", bytecodeStart=15, bytecodeLength=1) 1.13 + void m0(String[] args) { 1.14 + Object o; 1.15 + try { 1.16 + o = ""; 1.17 + o.hashCode(); 1.18 + } catch (RuntimeException e) {} 1.19 + o = ""; 1.20 + } 1.21 + 1.22 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) 1.23 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23) 1.24 + void m1() { 1.25 + Object o; 1.26 + try { 1.27 + o = ""; 1.28 + o.hashCode(); 1.29 + } catch (RuntimeException e) { 1.30 + } 1.31 + finally { 1.32 + o = "finally"; 1.33 + o.hashCode(); 1.34 + } 1.35 + o = ""; 1.36 + } 1.37 + 1.38 + @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) 1.39 + @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31) 1.40 + void m2() { 1.41 + Object o; 1.42 + try { 1.43 + o = ""; 1.44 + o.hashCode(); 1.45 + } catch (RuntimeException e) { 1.46 + o = "catch"; 1.47 + o.hashCode(); 1.48 + } 1.49 + finally { 1.50 + o = "finally"; 1.51 + o.hashCode(); 1.52 + } 1.53 + o = ""; 1.54 + } 1.55 + 1.56 + @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38) 1.57 + @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8) 1.58 + void m3() { 1.59 + Object o; 1.60 + try (BufferedReader br = 1.61 + new BufferedReader(new FileReader("aFile"))) { 1.62 + o = "inside try"; 1.63 + o.hashCode(); 1.64 + } catch (Exception e) {} 1.65 + o = ""; 1.66 + } 1.67 + 1.68 + @AliveRange(varName="o", bytecodeStart=12, bytecodeLength=96) 1.69 + @AliveRange(varName="o", bytecodeStart=112, bytecodeLength=1) 1.70 + void m4() { 1.71 + String o; 1.72 + try (BufferedReader br = 1.73 + new BufferedReader(new FileReader(o = "aFile"))) { 1.74 + o = "inside try"; 1.75 + o.hashCode(); 1.76 + } catch (Exception e) {} 1.77 + o = ""; 1.78 + } 1.79 +}