author | iignatyev |
Thu, 02 Aug 2018 14:40:55 -0700 | |
changeset 51287 | 7b1ddbafa134 |
parent 50385 | 50bfe66c499f |
permissions | -rw-r--r-- |
50385
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
1 |
/* |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
4 |
* |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
8 |
* |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
14 |
* |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
18 |
* |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
21 |
* questions. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
22 |
*/ |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
23 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
24 |
/** |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
25 |
* @test |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
26 |
* @summary Verifies NotifyFramePop request is cleared if JVMTI_EVENT_FRAME_POP is disabled |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50385
diff
changeset
|
27 |
* @library /test/lib |
50385
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
28 |
* @compile NotifyFramePopTest.java |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
29 |
* @run main/othervm/native -agentlib:NotifyFramePopTest NotifyFramePopTest |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
30 |
*/ |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
31 |
|
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50385
diff
changeset
|
32 |
import jtreg.SkippedException; |
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50385
diff
changeset
|
33 |
|
50385
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
34 |
public class NotifyFramePopTest { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
35 |
static { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
36 |
try { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
37 |
System.loadLibrary("NotifyFramePopTest"); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
38 |
} catch (UnsatisfiedLinkError ex) { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
39 |
System.err.println("Could not load NotifyFramePopTest library"); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
40 |
System.err.println("java.library.path:" |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
41 |
+ System.getProperty("java.library.path")); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
42 |
throw ex; |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
43 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
44 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
45 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
46 |
public static void main(String args[]) { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
47 |
if (!canGenerateFramePopEvents()) { |
51287
7b1ddbafa134
8208655: use JTreg skipped status in hotspot tests
iignatyev
parents:
50385
diff
changeset
|
48 |
throw new SkippedException("FramePop event is not supported"); |
50385
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
49 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
50 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
51 |
// Sanity testing that FRAME_POP works. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
52 |
test("sanity", true, () -> { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
53 |
setFramePopNotificationMode(true); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
54 |
notifyFramePop(null); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
55 |
}); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
56 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
57 |
// Request notification and then disable FRAME_POP event notification. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
58 |
// This should not prevent the notification for the frame being cleared |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
59 |
// when we return from the method. |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
60 |
test("requestAndDisable", false, () -> { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
61 |
setFramePopNotificationMode(true); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
62 |
notifyFramePop(null); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
63 |
setFramePopNotificationMode(false); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
64 |
}); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
65 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
66 |
// Ensure there is no pending event |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
67 |
test("ensureCleared", false, () -> { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
68 |
setFramePopNotificationMode(true); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
69 |
}); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
70 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
71 |
log("Test PASSED"); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
72 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
73 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
74 |
private native static boolean canGenerateFramePopEvents(); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
75 |
private native static void setFramePopNotificationMode(boolean enabled); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
76 |
private native static void notifyFramePop(Thread thread); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
77 |
private native static boolean framePopReceived(); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
78 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
79 |
private static void log(String msg) { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
80 |
System.out.println(msg); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
81 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
82 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
83 |
private interface Test { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
84 |
void test(); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
85 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
86 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
87 |
private static void test(String name, boolean framePopExpected, Test theTest) { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
88 |
log("test: " + name); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
89 |
theTest.test(); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
90 |
boolean actual = framePopReceived(); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
91 |
if (framePopExpected != actual) { |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
92 |
throw new RuntimeException("unexpected notification:" |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
93 |
+ " FramePop expected: " + (framePopExpected ? "yes" : "no") |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
94 |
+ ", actually received: " + (actual ? "yes" : "no")); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
95 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
96 |
log(" - OK (" + (actual ? "received" : "NOT received") + ")"); |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
97 |
} |
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
98 |
|
50bfe66c499f
8187289: NotifyFramePop request is not cleared if JVMTI_EVENT_FRAME_POP is disabled
amenkov
parents:
diff
changeset
|
99 |
} |