1 /*
2  * Copyright (c) 2001, 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 package nsk.jdi.EventSet.suspendPolicy;
25 
26 import nsk.share.*;
27 import nsk.share.jpda.*;
28 import nsk.share.jdi.*;
29 
30 /**
31  * This class is used as debuggee application for the suspendpolicy001 JDI test.
32  */
33 
34 public class suspendpolicy001a {
35 
36     //----------------------------------------------------- templete section
37 
38     static final int PASSED = 0;
39     static final int FAILED = 2;
40     static final int PASS_BASE = 95;
41 
42     static ArgumentHandler argHandler;
43     static Log log;
44 
45     //--------------------------------------------------   log procedures
46 
log1(String message)47     private static void log1(String message) {
48         log.display("**> debuggee: " + message);
49     }
50 
logErr(String message)51     private static void logErr(String message) {
52         log.complain("**> debuggee: " + message);
53     }
54 
55     //====================================================== test program
56     //------------------------------------------------------ common section
57 
58     static int exitCode = PASSED;
59 
60     static int instruction = 1;
61     static int end         = 0;
62                                    //    static int quit        = 0;
63                                    //    static int continue    = 2;
64     static int maxInstr    = 1;    // 2;
65 
66     static int lineForComm = 2;
67 
methodForCommunication()68     private static void methodForCommunication() {
69         int i1 = instruction;
70         int i2 = i1;
71         int i3 = i2;
72     }
73     //----------------------------------------------------   main method
74 
main(String argv[])75     public static void main (String argv[]) {
76 
77         argHandler = new ArgumentHandler(argv);
78         log = argHandler.createDebugeeLog();
79 
80         log1("debuggee started!");
81 
82         int exitCode = PASSED;
83 
84 
85         label0:
86             for (int i = 0; ; i++) {
87 
88                 if (instruction > maxInstr) {
89                     logErr("ERROR: unexpected instruction: " + instruction);
90                     exitCode = FAILED;
91                     break ;
92                 }
93 
94                 switch (i) {
95 
96     //------------------------------------------------------  section tested
97 
98 // Below, there is no the loop of interaction with the debugger for each Event
99 // because JVMS doesn't guaranties ordering ClassPrepareEvents.
100 // Therefore the debugger doesn't rely on the event order.
101 
102                     case 0:
103                             TestClass0 tcObject0 = new TestClass0();
104 //                          methodForCommunication();
105 //                          break;
106 
107                     case 1:
108                             TestClass1 tcObject1 = new TestClass1();
109 //                          methodForCommunication();
110 //                          break;
111                     case 2:
112                             TestClass2 tcObject2 = new TestClass2();
113 //                          methodForCommunication();
114 //                          break;
115 
116                     case 3:
117                             TestClass3 tcObject3 = new TestClass3();
118 //                          methodForCommunication();
119 //                          break;
120 
121                     case 4:
122                             TestClass4 tcObject4 = new TestClass4();
123 //                          methodForCommunication();
124 //                          break;
125 
126                     case 5:
127                             TestClass5 tcObject5 = new TestClass5();
128 //                          methodForCommunication();
129 //                          break;
130 
131                     case 6:
132                             TestClass6 tcObject6 = new TestClass6();
133 
134     //-------------------------------------------------    standard end section
135 
136                     default:
137                                 instruction = end;
138                                 methodForCommunication();
139                                 break label0;
140                 }
141             }
142 
143         System.exit(exitCode + PASS_BASE);
144     }
145 
146 }
147 class TestClass0 {
148     static int var1 = 0;
149 }
150 class TestClass1 {
151     static int var1 = 0;
152 }
153 class TestClass2 {
154     static int var1 = 0;
155 }
156 class TestClass3 {
157     static int var1 = 0;
158 }
159 class TestClass4 {
160     static int var1 = 0;
161 }
162 class TestClass5 {
163     static int var1 = 0;
164 }
165 class TestClass6 {
166     static int var1 = 0;
167 }
168