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  * @modules jdk.jdi/com.sun.tools.jdi:+open java.base/jdk.internal.misc:+open
28  *
29  * @summary converted from VM Testbase nsk/jdi/MonitorContendedEnterRequest/addClassFilter_ClassName.
30  * VM Testbase keywords: [quick, jpda, jdi, feature_jdk6_jpda, vm6]
31  * VM Testbase readme:
32  * DESCRIPTION
33  *         The test checks up that a result of the method com.sun.jdi.MonitorContendedEnterRequest.addClassFilter(String classPattern)
34  *         complies with its spec:
35  *         "Restricts the events generated by this request to the preparation of reference types whose name matches this
36  *         restricted regular expression. Regular expressions are limited to exact matches and patterns that begin
37  *         with '*' or end with '*'; for example, "*.Foo" or "java.*"."
38  *         Test also checks that received com.sun.jdi.MonitorContendedEnterEvent complies with its spec and contains correct data.
39  *         Test uses 3 different class patterns:
40  *                 - begins with '*' ('*Subclass')
41  *                 - ending  with '*' ('nsk.share.jdi.MonitorEnterExecutor_*')
42  *                 - class name ('nsk.share.jdi.MonitorEnterExecutor_1Subclass')
43  *         Test executes class nsk.share.jdi.EventTestTemplates$ClassExclusionFilterTest which uses JDI events testing
44  *         framework based on classes from package nsk.share.jdi.*.
45  *         This framework uses following scenario:
46  *                 - debugger VM forces debugge VM to create number of objects which should generate events during test
47  *                 - if any event filters are used each generating event object is checked is this object accepted by all filters,
48  *                 if object was accepted it should save information about all generated events and this information is available for debugger
49  *                 - debuggee performs event generation and stop at breakpoint
50  *                 - debugger reads data saved by debuggee's event generators and checks is only expected events was generated
51  *         Monitor enter events are generated in 3 different ways:
52  *                 - through synchronized block
53  *                 - through synchronized method
54  *                 - through JNI MonitorEnter
55  *         In addition to the main scenario tests using event filters also check following cases:
56  *                 - attempt to add filter to enabled or deleted request throws 'InvalidRequestStateException'
57  *                 - corresponding method EventRequestManager.xxxRequests() returns created event request
58  *
59  * @library /vmTestbase
60  *          /test/lib
61  * @run driver jdk.test.lib.FileInstaller . .
62  * @build nsk.share.jdi.EventTestTemplates
63  *        nsk.share.jdi.JDIEventsDebuggee
64  *        nsk.share.jdi.MonitorEventsDebuggee
65  * @run main/othervm/native PropertyResolvingWrapper
66  *      nsk.share.jdi.EventTestTemplates$ClassFilterTest_ClassName
67  *      -verbose
68  *      -arch=${os.family}-${os.simpleArch}
69  *      -waittime=5
70  *      -debugee.vmkind=java
71  *      -transport.address=dynamic
72  *      "-debugee.vmkeys=${test.vm.opts} ${test.java.opts}"
73  *      -allowMissedEvents MONITOR_CONTENTED_ENTER
74  *      -eventType MONITOR_CONTENTED_ENTER
75  *      -debuggeeClassName nsk.share.jdi.MonitorEventsDebuggee
76  *      -classPatterns nsk.share.jdi.MonitorEnterExecutor_'*':'*'Subclass:nsk.share.jdi.MonitorEnterExecutor_1Subclass
77  */
78 
79