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.resume;
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 resume001 JDI test.
32  */
33 
34 public class resume001a {
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     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 
83         label0:
84         for (int i = 0; ; i++) {
85 
86             log1("methodForCommunication();");
87             methodForCommunication();
88             if (instruction == end)
89                 break;
90 
91             if (instruction > maxInstr) {
92                 logErr("ERROR: unexpected instruction: " + instruction);
93                 exitCode = FAILED;
94                 break ;
95             }
96 
97             switch (i) {
98 
99 //------------------------------------------------------  section tested
100 
101                 case 0:
102                 TestClass2 obj2 = new TestClass2();
103                 break;
104 
105                 case 1:
106                 TestClass3 obj3 = new TestClass3();
107                 break;
108 
109                 case 2:
110                 TestClass4 obj4 = new TestClass4();
111 //-------------------------------------------------    standard end section
112 
113                 default:
114                 instruction = end;
115                 break label0;
116             }
117         }
118 
119         log1("debuggee exits");
120         System.exit(exitCode + PASS_BASE);
121     }
122 }
123 
124 class TestClass2 {
125     static int var1 = 0;
126 }
127 
128 class TestClass3 {
129     static int var1 = 0;
130 }
131 
132 class TestClass4 {
133     static int var1 = 0;
134 }
135