
Untitled
By: a guest on
Aug 5th, 2012 | syntax:
None | size: 1.94 KB | hits: 14 | expires: Never
Variable gets garbage collected inmediately after catch block
public class A {
public static void main(String[] args) {
String foo;
try {
foo = "bar";
int yoo = 5; //1
} catch (Exception e) {
}
int foobar = 3;//2
}
}
public class A {
public static void main(String[] args) {
String foo;
try {
foo = "bar";
} catch (Exception e) {
throw new RuntimeException(e);
}
int foobar = 3;
}
}
public static void main(java.lang.String[]);
Code:
0: ldc #2 // String bar
2: astore_1
3: iconst_5
4: istore_2
5: goto 9
8: astore_2
9: iconst_3
10: istore_2
11: return
public static void main(java.lang.String[]);
Code:
0: aconst_null
1: astore_1
2: ldc #2 // String bar
4: astore_1
5: iconst_5
6: istore_2
7: goto 11
10: astore_2
11: iconst_3
12: istore_2
13: return
public static void main(String[] args){
String foo;
char[] c = null;
try {
foo = "bar";
c = foo.toCharArray();
int yoo = 5; //1
} catch (Exception e) {
}
int foobar = 3;//2
}
public static void main(String[] args){
String foo;
List<String> list = new ArrayList<String>();
try {
foo = "bar";
list.add(foo);
int yoo = 5; //1
} catch (Exception e) {
}
int foobar = 3;//2
}
public static void main(java.lang.String[]);
Code:
0: ldc #2 // String bar
2: astore_1
3: iconst_5
4: istore_2
5: goto 9
8: astore_2
9: iconst_3
10: istore_2
11: return
Exception table:
from to target type
0 5 8 Class java/lang/Exception