1 /*
2  * Copyright (C) 2007 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 public class Blort
18 {
caught()19     public static void caught() {
20         // This space intentionally left blank.
21     }
22 
zorch(int x)23     public static void zorch(int x) {
24         // This space intentionally left blank.
25     }
26 
test1(int x)27     public static void test1(int x) {
28         // In this test, the code being try-caught can't possibly throw.
29         try {
30             x = 0;
31         } catch (RuntimeException ex) {
32             caught();
33         }
34     }
35 
test2(String[] sa)36     public static void test2(String[] sa) {
37         // In this test, the code being try-caught doesn't contain any
38         // constant pool references.
39         try {
40             int x = sa.length;
41         } catch (RuntimeException ex) {
42             caught();
43         }
44     }
45 
test3()46     public static void test3() {
47         // In this test, the code being try-caught contains a constant
48         // pool reference.
49         try {
50             zorch(1);
51         } catch (RuntimeException ex) {
52             caught();
53         }
54     }
55 
test4(String[] sa)56     public static void test4(String[] sa) {
57         // In this test, the code being try-caught contains one
58         // throwing instruction that has a constant pool reference and
59         // one that doesn't.
60         try {
61             zorch(sa.length);
62         } catch (RuntimeException ex) {
63             caught();
64         }
65     }
66 }
67