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.Location.method;
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 method001 JDI test.
32  */
33 
34 public class method001a {
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     //--------------------------------------------------   log procedures
43 
44     static boolean verbMode = false;
45 
log1(String message)46     public static void log1(String message) {
47         if (verbMode)
48             System.err.println("**> method001a: " + message);
49     }
50 
logErr(String message)51     private static void logErr(String message) {
52         if (verbMode)
53             System.err.println("!!**> method001a: " + message);
54     }
55 
56     //====================================================== test program
57 
58     static TestClass obj = new TestClass();
59 
60     //----------------------------------------------------   main method
61 
main(String argv[])62     public static void main (String argv[]) {
63 
64         for (int i=0; i<argv.length; i++) {
65             if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) {
66                 verbMode = true;
67                 break;
68             }
69         }
70         log1("debuggee started!");
71 
72         // informing a debugger of readyness
73         ArgumentHandler argHandler = new ArgumentHandler(argv);
74         IOPipe pipe = argHandler.createDebugeeIOPipe();
75         pipe.println("ready");
76 
77 
78         int exitCode = PASSED;
79         for (int i = 0; ; i++) {
80 
81             String instruction;
82 
83             log1("waiting for an instruction from the debugger ...");
84             instruction = pipe.readln();
85             if (instruction.equals("quit")) {
86                 log1("'quit' recieved");
87                 break ;
88 
89             } else if (instruction.equals("newcheck")) {
90                 switch (i) {
91 
92     //------------------------------------------------------  section tested
93 
94                 case 0:
95                                 pipe.println("checkready");
96                                 break ;
97 
98     //-------------------------------------------------    standard end section
99 
100                 default:
101                                 pipe.println("checkend");
102                                 break ;
103                 }
104 
105             } else {
106                 logErr("ERRROR: unexpected instruction: " + instruction);
107                 exitCode = FAILED;
108                 break ;
109             }
110         }
111 
112         System.exit(exitCode + PASS_BASE);
113     }
114 }
115 
116 
117 class TestClass extends Object {
118 
TestClass()119     public TestClass() {
120         super();
121     }
122 
testMethod(int param)123     public  void testMethod (int param) {
124 
125         boolean bl1 = false, bl2 = true;
126         byte    bt1 = 0,     bt2 = 1;
127         char    ch1 = 0,     ch2 = 1;
128 
129         return;
130     }
131 
132     static String s0 = Integer.toString(123);
133 
134 //    public native void nativeMethod();
135 
136 //    public abstract void abstractMethod();
137 
138 /*
139     String s1 = Integer.toString(456);
140     String s2 = Integer.toString(789);
141     String s3 = Integer.toString(321);
142     String s4 = Integer.toString(654);
143     String s5 = Integer.toString(987);
144 */
145 }
146