This repository was archived by the owner on Jul 12, 2023. It is now read-only.
forked from polyglot-compiler/JLang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExceptionReturnTest.java
68 lines (62 loc) · 1.78 KB
/
ExceptionReturnTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
public class ExceptionReturnTest {
public static void main(String[] args) {
System.out.println(retBoth());
System.out.println(retCatch());
System.out.println(retFinally());
System.out.println(retAfter());
retCatchVoid();
}
public static String retBoth(){
try {
throw new Exception();
} catch (Exception e) {
System.out.println("C");
return "DO NOT PRINT";
} finally {
System.out.println("F");
return "CORRECT RETURN -- retBoth";
}
}
public static String retCatch(){
try {
throw new Exception();
} catch (Exception e) {
System.out.println("retCatch -- C");
return "RETURN retCatch";
} finally {
System.out.println("retCatch -- F");
}
}
public static String retFinally(){
try {
throw new Exception();
} catch (Exception e) {
System.out.println("retFinally -- C");
} finally {
System.out.println("retFinally -- F");
return "RETURN retFinally";
}
}
public static String retAfter(){
try {
throw new Exception();
} catch (Exception e) {
System.out.println("retAfter -- C");
} finally {
System.out.println("retAfter -- F");
}
return "RETURN retAfter";
}
public static void retCatchVoid(){
try {
throw new Exception();
} catch (Exception e) {
System.out.println("retCatchVoid -- C");
if(true)
return;
} finally {
System.out.println("retCatchVoid -- F");
}
System.out.println("DO NOT PRINT THIS");
}
}