Sat, 14 Sep 2013 19:04:47 +0100
7047734: javac, the LVT is not generated correctly in several scenarios
Reviewed-by: jjg, mcimadamore
aoqi@0 | 1 | /* /nodynamiccopyright/ */ |
aoqi@0 | 2 | |
aoqi@0 | 3 | import java.io.BufferedReader; |
aoqi@0 | 4 | import java.io.FileReader; |
aoqi@0 | 5 | |
aoqi@0 | 6 | public class TestCaseTry { |
aoqi@0 | 7 | |
aoqi@0 | 8 | @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=8) |
aoqi@0 | 9 | @AliveRange(varName="o", bytecodeStart=15, bytecodeLength=1) |
aoqi@0 | 10 | void m0(String[] args) { |
aoqi@0 | 11 | Object o; |
aoqi@0 | 12 | try { |
aoqi@0 | 13 | o = ""; |
aoqi@0 | 14 | o.hashCode(); |
aoqi@0 | 15 | } catch (RuntimeException e) {} |
aoqi@0 | 16 | o = ""; |
aoqi@0 | 17 | } |
aoqi@0 | 18 | |
aoqi@0 | 19 | @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) |
aoqi@0 | 20 | @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=23) |
aoqi@0 | 21 | void m1() { |
aoqi@0 | 22 | Object o; |
aoqi@0 | 23 | try { |
aoqi@0 | 24 | o = ""; |
aoqi@0 | 25 | o.hashCode(); |
aoqi@0 | 26 | } catch (RuntimeException e) { |
aoqi@0 | 27 | } |
aoqi@0 | 28 | finally { |
aoqi@0 | 29 | o = "finally"; |
aoqi@0 | 30 | o.hashCode(); |
aoqi@0 | 31 | } |
aoqi@0 | 32 | o = ""; |
aoqi@0 | 33 | } |
aoqi@0 | 34 | |
aoqi@0 | 35 | @AliveRange(varName="o", bytecodeStart=3, bytecodeLength=16) |
aoqi@0 | 36 | @AliveRange(varName="o", bytecodeStart=23, bytecodeLength=31) |
aoqi@0 | 37 | void m2() { |
aoqi@0 | 38 | Object o; |
aoqi@0 | 39 | try { |
aoqi@0 | 40 | o = ""; |
aoqi@0 | 41 | o.hashCode(); |
aoqi@0 | 42 | } catch (RuntimeException e) { |
aoqi@0 | 43 | o = "catch"; |
aoqi@0 | 44 | o.hashCode(); |
aoqi@0 | 45 | } |
aoqi@0 | 46 | finally { |
aoqi@0 | 47 | o = "finally"; |
aoqi@0 | 48 | o.hashCode(); |
aoqi@0 | 49 | } |
aoqi@0 | 50 | o = ""; |
aoqi@0 | 51 | } |
aoqi@0 | 52 | |
aoqi@0 | 53 | @AliveRange(varName="o", bytecodeStart=22, bytecodeLength=38) |
aoqi@0 | 54 | @AliveRange(varName="o", bytecodeStart=103, bytecodeLength=8) |
aoqi@0 | 55 | void m3() { |
aoqi@0 | 56 | Object o; |
aoqi@0 | 57 | try (BufferedReader br = |
aoqi@0 | 58 | new BufferedReader(new FileReader("aFile"))) { |
aoqi@0 | 59 | o = "inside try"; |
aoqi@0 | 60 | o.hashCode(); |
aoqi@0 | 61 | } catch (Exception e) {} |
aoqi@0 | 62 | o = ""; |
aoqi@0 | 63 | } |
aoqi@0 | 64 | |
aoqi@0 | 65 | @AliveRange(varName="o", bytecodeStart=12, bytecodeLength=96) |
aoqi@0 | 66 | @AliveRange(varName="o", bytecodeStart=112, bytecodeLength=1) |
aoqi@0 | 67 | void m4() { |
aoqi@0 | 68 | String o; |
aoqi@0 | 69 | try (BufferedReader br = |
aoqi@0 | 70 | new BufferedReader(new FileReader(o = "aFile"))) { |
aoqi@0 | 71 | o = "inside try"; |
aoqi@0 | 72 | o.hashCode(); |
aoqi@0 | 73 | } catch (Exception e) {} |
aoqi@0 | 74 | o = ""; |
aoqi@0 | 75 | } |
aoqi@0 | 76 | } |