1 /*
2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * This code is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 only, as
7  * published by the Free Software Foundation.
8  *
9  * This code is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12  * version 2 for more details (a copy is included in the LICENSE file that
13  * accompanied this code).
14  *
15  * You should have received a copy of the GNU General Public License version
16  * 2 along with this work; if not, write to the Free Software Foundation,
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18  *
19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20  * or visit www.oracle.com if you need additional information or have any
21  * questions.
22  */
23 
24 /*
25  * @test
26  *
27  * @summary converted from VM Testbase jit/t/t057.
28  * VM Testbase keywords: [jit, quick]
29  *
30  * @library /vmTestbase
31  *          /test/lib
32  * @run driver jdk.test.lib.FileInstaller . .
33  * @build jit.t.t057.t057
34  * @run driver ExecDriver --java jit.t.t057.t057
35  */
36 
37 package jit.t.t057;
38 
39 import nsk.share.TestFailure;
40 import nsk.share.GoldChecker;
41 
42 // Just like t056 except here the exception is not explicitly thrown.
43 
44 class t057
45 {
46     public static final GoldChecker goldChecker = new GoldChecker( "t057" );
47 
48     static int i;
49     static int j;
50 
51     // Routine nest in which exception is thrown and caught in
52     // the fourth routine.
53 
r14()54     static void r14(){r24();}
r24()55     static void r24(){r34();}
r34()56     static void r34(){r44();}
r44()57     static void r44()
58     {
59         try
60         {
61             i/=j;
62         }
63         catch(Throwable t)
64         {
65             t057.goldChecker.println("caught in r44");
66         }
67     }
68 
69     // Thrown in the fourth; caught in the third.
70 
r13()71     static void r13(){r23();}
r23()72     static void r23(){r33();}
r33()73     static void r33()
74     {
75         try
76         {
77             r43();
78         }
79         catch(Throwable t)
80         {
81             t057.goldChecker.println("caught in r33");
82         }
83     }
r43()84     static void r43() throws Throwable
85     {
86         i/=j;
87     }
88 
89     // Thrown in fourth; caught in second.
90 
r12()91     static void r12(){r22();}
r22()92     static void r22()
93     {
94         try
95         {
96             r32();
97         }
98         catch(Throwable t)
99         {
100             t057.goldChecker.println("caught in r22");
101         }
102     }
r32()103     static void r32() throws Throwable {r42();}
r42()104     static void r42() throws Throwable
105     {
106         i/=j;
107     }
108 
109     // Thrown in fourth; caught in first.
110 
r11()111     static void r11()
112     {
113         try
114         {
115             r21();
116         }
117         catch(Throwable t)
118         {
119             t057.goldChecker.println("caught in r11");
120         }
121     }
r21()122     static void r21() throws Throwable {r31();}
r31()123     static void r31() throws Throwable {r41();}
r41()124     static void r41() throws Throwable
125     {
126         i/=j;
127     }
128 
main(String argv[])129     public static void main(String argv[])
130     {
131         t057.goldChecker.print("Calling r14: "); r14();
132         t057.goldChecker.print("Calling r13: "); r13();
133         t057.goldChecker.print("Calling r12: "); r12();
134         t057.goldChecker.print("Calling r11: "); r11();
135                                            t057.goldChecker.check();
136     }
137 }
138