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.ClassType.concreteMethodByName; 25 26 import nsk.share.*; 27 import nsk.share.jpda.*; 28 import nsk.share.jdi.*; 29 30 31 /** 32 * This class is used as debuggee application for the method001 JDI test. 33 */ 34 35 public class method001a { 36 37 //----------------------------------------------------- templete section 38 39 static final int PASSED = 0; 40 static final int FAILED = 2; 41 static final int PASS_BASE = 95; 42 43 //-------------------------------------------------- log procedures 44 45 static boolean verbMode = false; // debugger may switch to true 46 log1(String message)47 private static void log1(String message) { 48 if (verbMode) 49 System.err.println("**> method001a: " + message); 50 } 51 logErr(String message)52 private static void logErr(String message) { 53 if (verbMode) 54 System.err.println("!!**> method001a: " + message); 55 } 56 57 //====================================================== test program 58 59 static Class1ForCheck class1 = null; 60 static Class2ForCheck class2 = null; 61 62 //---------------------------------------------------- main method 63 main(String argv[])64 public static void main (String argv[]) { 65 66 for (int i=0; i<argv.length; i++) { 67 if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) { 68 verbMode = true; 69 break; 70 } 71 } 72 log1("debuggee started!"); 73 74 // informing a debugger of readyness 75 ArgumentHandler argHandler = new ArgumentHandler(argv); 76 IOPipe pipe = argHandler.createDebugeeIOPipe(); 77 pipe.println("ready"); 78 79 80 int exitCode = PASSED; 81 for (int i = 0; ; i++) { 82 83 String instruction; 84 85 log1("waiting for an instruction from the debugger ..."); 86 instruction = pipe.readln(); 87 if (instruction.equals("quit")) { 88 log1("'quit' recieved"); 89 break ; 90 91 } else if (instruction.equals("newcheck")) { 92 switch (i) { 93 94 //------------------------------------------------------ section tested 95 96 case 0: 97 class1 = new Class1ForCheck(); 98 class2 = new Class2ForCheck(); 99 100 pipe.println("checkready"); 101 break ; 102 103 //------------------------------------------------- standard end section 104 105 default: 106 pipe.println("checkend"); 107 break ; 108 } 109 110 } else { 111 logErr("ERRROR: unexpected instruction: " + instruction); 112 exitCode = FAILED; 113 break ; 114 } 115 } 116 117 System.exit(exitCode + PASS_BASE); 118 } 119 } 120 121 class Class1ForCheck { 122 123 // static fields 124 125 static boolean s_boolean; 126 static byte s_byte; 127 static char s_char; 128 static double s_double; 129 static float s_float; 130 static int s_int; 131 static long s_long; 132 static Object s_object; 133 static int[] s_int_array = {1,2}; 134 static Object[] s_ref_array; 135 136 // instance fields 137 138 boolean i_boolean; 139 byte i_byte; 140 char i_char; 141 double i_double; 142 float i_float; 143 int i_int; 144 long i_long; 145 Object i_object; 146 long[] i_prim_array; 147 Object[] i_ref_array; 148 149 blValue()150 public boolean blValue() { 151 return true; 152 } btValue()153 public byte btValue() { 154 return 1; 155 } chValue()156 public char chValue() { 157 return 1; 158 } dbValue()159 public double dbValue() { 160 return 1.0d; 161 } flValue()162 public float flValue() { 163 return 1.0f; 164 } inValue()165 public int inValue() { 166 return 1; 167 } lnValue()168 public long lnValue() { 169 return 1; 170 } shValue()171 public short shValue() { 172 return 1; 173 } vdValue()174 public void vdValue() { 175 return ; 176 } 177 178 inArray()179 public int[] inArray() { 180 return s_int_array; 181 } 182 183 184 static Class2ForCheck classObj = null; 185 classMethod()186 public Class2ForCheck classMethod() { 187 classObj = new Class2ForCheck(); 188 return classObj; 189 } 190 191 192 static IfaceForCheck ifaceObj = null; 193 ifaceMethod()194 public IfaceForCheck ifaceMethod() { 195 ifaceObj = new Class2ForCheck(); 196 return ifaceObj; 197 } 198 } 199 200 201 interface IfaceForCheck { 202 static int ival = 1; 203 } 204 205 // class Class2ForCheck extends Class1ForCheck { 206 207 class Class2ForCheck implements IfaceForCheck { 208 method2()209 int method2() { 210 return 1; 211 } 212 213 // static fields 214 215 static boolean s_boolean; 216 static byte s_byte; 217 static char s_char; 218 static double s_double; 219 static float s_float; 220 static int s_int; 221 static long s_long; 222 static Object s_object; 223 static long[] s_prim_array; 224 static Object[] s_ref_array; 225 226 // instance fields 227 228 boolean i_boolean; 229 byte i_byte; 230 char i_char; 231 double i_double; 232 float i_float; 233 int i_int; 234 long i_long; 235 Object i_object; 236 long[] i_prim_array; 237 Object[] i_ref_array; 238 } 239