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.IsObsolete command. 39 */ 40 public class IsObsoleteTest extends JDWPMethodTestCase { 41 /** 42 * This testcase exercises Method.IsObsolete command. 43 * <BR>It runs MethodDebuggee, receives checked method, 44 * which is not obsolete, and checks it with Method.IsObsolete command. 45 */ testIsObsoleteTest001()46 public void testIsObsoleteTest001() throws UnsupportedEncodingException { 47 logWriter.println("testObsoleteTest001 started"); 48 49 //check capability, relevant for this test 50 logWriter.println("=> Check, can VM redefine classes"); 51 debuggeeWrapper.vmMirror.capabilities(); 52 boolean isCapability = debuggeeWrapper.vmMirror.targetVMCapabilities.canRedefineClasses; 53 if (!isCapability) { 54 logWriter.println("##WARNING: this VM can't redefine classes"); 55 return; 56 } 57 58 synchronizer.receiveMessage(JPDADebuggeeSynchronizer.SGNL_READY); 59 60 long classID = getClassIDBySignature("L"+getDebuggeeClassName().replace('.', '/')+";"); 61 62 MethodInfo[] methodsInfo = jdwpGetMethodsInfo(classID); 63 assertFalse("Invalid number of methods", methodsInfo.length == 0); 64 65 for (int i = 0; i < methodsInfo.length; i++) { 66 logWriter.println(methodsInfo[i].toString()); 67 68 // get variable table for this class 69 CommandPacket packet = new CommandPacket( 70 JDWPCommands.MethodCommandSet.CommandSetID, 71 JDWPCommands.MethodCommandSet.IsObsoleteCommand); 72 packet.setNextValueAsClassID(classID); 73 packet.setNextValueAsMethodID(methodsInfo[i].getMethodID()); 74 ReplyPacket reply = debuggeeWrapper.vmMirror.performCommand(packet); 75 checkReplyPacket(reply, "Method::IsObsolete command"); 76 77 boolean isObsolete = reply.getNextValueAsBoolean(); 78 logWriter.println("isObsolete=" + isObsolete); 79 } 80 81 synchronizer.sendMessage(JPDADebuggeeSynchronizer.SGNL_CONTINUE); 82 } 83 } 84