1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 /** 20 * @author Anton V. Karnachuk 21 */ 22 23 /** 24 * Created on 14.02.2005 25 */ 26 package org.apache.harmony.jpda.tests.jdwp.Method; 27 28 import java.io.UnsupportedEncodingException; 29 30 import org.apache.harmony.jpda.tests.framework.jdwp.CommandPacket; 31 import org.apache.harmony.jpda.tests.framework.jdwp.JDWPCommands; 32 import org.apache.harmony.jpda.tests.framework.jdwp.ReplyPacket; 33 import org.apache.harmony.jpda.tests.share.JPDADebuggeeSynchronizer; 34 35 36 37 /** 38 * JDWP Unit test for Method.VariableTableWithGeneric command. 39 */ 40 41 public class VariableTableWithGenericTest extends JDWPMethodTestCase { 42 /** 43 * This testcase exercises Method.VariableTableWithGeneric command. 44 * <BR>It runs MethodDebuggee, receives methods of debuggee. 45 * For each received method sends Method.VariableTableWithGeneric command 46 * and prints returned VariableTable. 47 */ testVariableTableWithGenericTest001()48 public void testVariableTableWithGenericTest001() throws UnsupportedEncodingException { 49 logWriter.println("VariableTableWithGeneric started"); 50 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 51 52 long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";"); 53 54 MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID); 55 assertFalse("Invalid number of methods: 0", methodsInfo.length == 0); 56 57 for (int i = 0; i < methodsInfo.length; i++) { 58 logWriter.println(methodsInfo[i].toString()); 59 60 // get variable table for this class 61 CommandPacket packet = new CommandPacket( 62 JDWPCommands.MethodCommandSet.CommandSetID, 63 JDWPCommands.MethodCommandSet.VariableTableWithGenericCommand); 64 packet.setNextValueAsClassID(classID); 65 packet.setNextValueAsMethodID(methodsInfo[i].getMethodID()); 66 ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet); 67 checkReplyPacket(reply, "Method::VariableTableWithGeneric command"); 68 69 int argCnt = reply.getNextValueAsInt(); 70 logWriter.println("argCnt = "+argCnt); 71 int slots = reply.getNextValueAsInt(); 72 logWriter.println("slots = "+slots); 73 for (int j = 0; j < slots; j++) { 74 long codeIndex = reply.getNextValueAsLong(); 75 logWriter.println("codeIndex = "+codeIndex); 76 String name = reply.getNextValueAsString(); 77 logWriter.println("name = "+name); 78 String signature = reply.getNextValueAsString(); 79 logWriter.println("signature = "+signature); 80 String genericSignature = reply.getNextValueAsString(); 81 logWriter.println("genericSignature = "+genericSignature); 82 int length = reply.getNextValueAsInt(); 83 logWriter.println("length = "+length); 84 int slot = reply.getNextValueAsInt(); 85 logWriter.println("slot = "+slot); 86 } 87 } 88 89 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 90 } 91 } 92