1 /* 2 * Copyright (c) 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 25 /* 26 * @test 27 * 28 * @summary converted from VM Testbase nsk/jdi/StepRequest/addInstanceFilter/instancefilter004. 29 * VM Testbase keywords: [quick, jpda, jdi] 30 * VM Testbase readme: 31 * DESCRIPTION: 32 * The test for the implementation of an object of the type 33 * StepRequest. 34 * The test checks up that a result of the method 35 * com.sun.jdi.StepRequest.addInstanceFilter() 36 * complies with its spec: 37 * public void addInstanceFilter(ObjectReference instance) 38 * Restricts the events generated by this request to those in which 39 * the currently executing instance is the object specified. 40 * Not all targets support this operation. 41 * Use VirtualMachine.canUseInstanceFilters() to determine 42 * if the operation is supported. 43 * Parameters: instance - the object which must be the current instance 44 * in order to pass this filter. 45 * Throws: UnsupportedOperationException - 46 * if the target virtual machine does not support this operation. 47 * InvalidRequestStateException - 48 * if this request is currently enabled or has been deleted. 49 * Filters may be added only to disabled requests. 50 * The test checks up on the following assertion: 51 * Restricts the events generated by this request to those in which 52 * the currently executing instance is the object specified. 53 * The cases to test includes re-invocation of the method 54 * addInstanceFilter() on the same StepRequest object. 55 * There are two StepRequests to check as follows: 56 * (1) For StepRequest2, both invocations are with different 57 * ObjectReferences restricting one Step event to two objects. 58 * The test expects no Step event will be received. 59 * (2) For StepRequest1, both invocations are with the same 60 * ObjectReference restricting one Step event to one object. 61 * The test expects this Step event will be received. 62 * The test works as follows: 63 * The debugger program - nsk.jdi.StepRequest.addInstanceFilter.instancefilter001; 64 * the debuggee program - nsk.jdi.StepRequest.addInstanceFilter.instancefilter001a. 65 * Using nsk.jdi.share classes, 66 * the debugger gets the debuggee running on another JavaVM, 67 * creates the object debuggee.VM, and waits for VMStartEvent. 68 * Upon getting the debuggee VM started, 69 * the debugger calls corresponding debuggee.VM methods to get 70 * needed data and to perform checks. 71 * In case of error the test produces the return value 97 and 72 * a corresponding error message(s). 73 * Otherwise, the test is passed and produces 74 * the return value 95 and no message. 75 * COMMENTS: 76 * The test was fixed due to bug: 77 * 4687906 TEST_BUG: some tests for jdi StepRequest are invalid 78 * Modified due to fix of the bug: 79 * 4930911 TEST_BUG: filter_rt006 debuggee has a race 80 * 81 * @library /vmTestbase 82 * /test/lib 83 * @run driver jdk.test.lib.FileInstaller . . 84 * @build nsk.jdi.StepRequest.addInstanceFilter.instancefilter004 85 * nsk.jdi.StepRequest.addInstanceFilter.instancefilter004a 86 * @run main/othervm PropertyResolvingWrapper 87 * nsk.jdi.StepRequest.addInstanceFilter.instancefilter004 88 * -verbose 89 * -arch=${os.family}-${os.simpleArch} 90 * -waittime=5 91 * -debugee.vmkind=java 92 * -transport.address=dynamic 93 * "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}" 94 */ 95 96