Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 5th, 2012  |  syntax: None  |  size: 1.94 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Variable gets garbage collected inmediately after catch block
  2. public class A {
  3.     public static void main(String[] args) {
  4.  
  5.         String foo;
  6.         try {
  7.             foo = "bar";
  8.  
  9.             int yoo = 5; //1
  10.         } catch (Exception e) {
  11.         }
  12.  
  13.         int foobar = 3;//2
  14.     }
  15. }
  16.        
  17. public class A {
  18.     public static void main(String[] args) {
  19.  
  20.         String foo;
  21.         try {
  22.             foo = "bar";
  23.         } catch (Exception e) {
  24.             throw new RuntimeException(e);
  25.         }
  26.  
  27.         int foobar = 3;
  28.     }
  29. }
  30.        
  31. public static void main(java.lang.String[]);
  32. Code:
  33.    0: ldc           #2                  // String bar
  34.    2: astore_1      
  35.    3: iconst_5      
  36.    4: istore_2      
  37.    5: goto          9
  38.    8: astore_2      
  39.    9: iconst_3      
  40.   10: istore_2      
  41.   11: return
  42.        
  43. public static void main(java.lang.String[]);
  44. Code:
  45.    0: aconst_null  
  46.    1: astore_1      
  47.    2: ldc           #2                  // String bar
  48.    4: astore_1      
  49.    5: iconst_5      
  50.    6: istore_2      
  51.    7: goto          11
  52.   10: astore_2      
  53.   11: iconst_3      
  54.   12: istore_2      
  55.   13: return
  56.        
  57. public static void main(String[] args){
  58.     String foo;
  59.     char[] c = null;
  60.     try {
  61.         foo = "bar";
  62.         c = foo.toCharArray();
  63.  
  64.         int yoo = 5; //1
  65.     } catch (Exception e) {
  66.     }
  67.  
  68.     int foobar = 3;//2
  69. }
  70.        
  71. public static void main(String[] args){
  72.     String foo;
  73.     List<String> list = new ArrayList<String>();
  74.  
  75.     try {
  76.         foo = "bar";
  77.         list.add(foo);
  78.         int yoo = 5; //1
  79.     } catch (Exception e) {
  80.     }
  81.  
  82.     int foobar = 3;//2
  83.  
  84. }
  85.        
  86. public static void main(java.lang.String[]);
  87.     Code:
  88.        0: ldc           #2                  // String bar
  89.        2: astore_1
  90.        3: iconst_5
  91.        4: istore_2
  92.        5: goto          9
  93.        8: astore_2
  94.        9: iconst_3
  95.       10: istore_2
  96.       11: return
  97.     Exception table:
  98.        from    to  target type
  99.            0     5     8   Class java/lang/Exception