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.Method.argumentTypes; 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 argumenttypes001 JDI test. 33 */ 34 35 public class argumenttypes001a { 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("**> argumenttypes001a: " + message); 50 } 51 logErr(String message)52 private static void logErr(String message) { 53 if (verbMode) 54 System.err.println("!!**> argumenttypes001a: " + message); 55 } 56 57 //====================================================== test program 58 59 static argumenttypes001aTestClass obj = new argumenttypes001aTestClass(); 60 61 //---------------------------------------------------- main method 62 main(String argv[])63 public static void main (String argv[]) { 64 65 for (int i=0; i<argv.length; i++) { 66 if ( argv[i].equals("-vbs") || argv[i].equals("-verbose") ) { 67 verbMode = true; 68 break; 69 } 70 } 71 log1("debuggee started!"); 72 73 // informing a debugger of readyness 74 ArgumentHandler argHandler = new ArgumentHandler(argv); 75 IOPipe pipe = argHandler.createDebugeeIOPipe(); 76 pipe.println("ready"); 77 78 79 int exitCode = PASSED; 80 for (int i = 0; ; i++) { 81 82 String instruction; 83 84 log1("waiting for an instruction from the debugger ..."); 85 instruction = pipe.readln(); 86 if (instruction.equals("quit")) { 87 log1("'quit' recieved"); 88 break ; 89 90 } else if (instruction.equals("newcheck")) { 91 switch (i) { 92 93 //------------------------------------------------------ section tested 94 95 case 0: 96 pipe.println("checkready"); 97 break ; 98 99 //------------------------------------------------- standard end section 100 101 default: 102 pipe.println("checkend"); 103 break ; 104 } 105 106 } else { 107 logErr("ERRROR: unexpected instruction: " + instruction); 108 exitCode = FAILED; 109 break ; 110 } 111 } 112 113 System.exit(exitCode + PASS_BASE); 114 } 115 } 116 117 class argumenttypes001aTestClass { 118 119 bl()120 public boolean bl () { return false; } bt()121 public byte bt () { return 0; } ch()122 public char ch () { return 0; } db()123 public double db () { return 0.0d; } fl()124 public float fl () { return 0.0f; } in()125 public int in () { return 0; } ln()126 public long ln () { return 0; } sh()127 public short sh () { return 0; } 128 vd()129 public void vd () { return ; } 130 131 132 primitiveargsmethod( boolean bl, byte bt, char ch, double db, float fl, int in, long l, short sh )133 public void primitiveargsmethod ( boolean bl, 134 byte bt, 135 char ch, 136 double db, 137 float fl, 138 int in, 139 long l, 140 short sh ) { 141 return ; 142 } 143 144 145 146 private argumenttypes001aClassForCheck2 class2 = new argumenttypes001aClassForCheck2(); 147 148 private argumenttypes001aClassForCheck1 classFC1 = new argumenttypes001aClassForCheck1(); 149 private argumenttypes001aIntfForCheck iface1 = class2; 150 private argumenttypes001aClassForCheck1 cfc1[] = { new argumenttypes001aClassForCheck1(), new argumenttypes001aClassForCheck1() }; 151 arrayargmethod(argumenttypes001aClassForCheck1 cfc[])152 public argumenttypes001aClassForCheck1[] arrayargmethod (argumenttypes001aClassForCheck1 cfc[]) { 153 return cfc; 154 } classargmethod(argumenttypes001aClassForCheck1 classFC)155 public argumenttypes001aClassForCheck1 classargmethod (argumenttypes001aClassForCheck1 classFC) { 156 return classFC; 157 } ifaceargmethod(argumenttypes001aIntfForCheck iface)158 public argumenttypes001aIntfForCheck ifaceargmethod (argumenttypes001aIntfForCheck iface) { 159 return iface; 160 } 161 162 } 163 164 165 interface argumenttypes001aIntfForCheck { 166 167 // static final boolean s_iface_boolean = true; 168 static final byte s_iface_byte = (byte)1; 169 static final char s_iface_char = '1'; 170 static final double s_iface_double = 999; 171 static final float s_iface_float = 99; 172 static final int s_iface_int = 100; 173 static final long s_iface_long = 1000; 174 static final Object s_iface_object = new Object(); 175 } 176 177 class argumenttypes001aClassForCheck2 implements argumenttypes001aIntfForCheck { 178 } 179 180 class argumenttypes001aClassForCheck1 { 181 182 // static fields 183 static boolean bl[] = {true, false}; 184 185 static boolean s_boolean; 186 static byte s_byte; 187 static char s_char; 188 static double s_double; 189 static float s_float; 190 static int s_int; 191 static long s_long; 192 193 // instance fields 194 195 boolean i_boolean; 196 byte i_byte; 197 char i_char; 198 double i_double; 199 float i_float; 200 int i_int; 201 long i_long; 202 } 203