Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/hotspot/jtreg/serviceability/jvmti/NotifyFramePop/NotifyFramePopTest.java
41153 views
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
* @test
26
* @summary Verifies NotifyFramePop request is cleared if JVMTI_EVENT_FRAME_POP is disabled
27
* @requires vm.jvmti
28
* @library /test/lib
29
* @compile NotifyFramePopTest.java
30
* @run main/othervm/native -agentlib:NotifyFramePopTest NotifyFramePopTest
31
*/
32
33
import jtreg.SkippedException;
34
35
public class NotifyFramePopTest {
36
static {
37
try {
38
System.loadLibrary("NotifyFramePopTest");
39
} catch (UnsatisfiedLinkError ex) {
40
System.err.println("Could not load NotifyFramePopTest library");
41
System.err.println("java.library.path:"
42
+ System.getProperty("java.library.path"));
43
throw ex;
44
}
45
}
46
47
public static void main(String args[]) {
48
if (!canGenerateFramePopEvents()) {
49
throw new SkippedException("FramePop event is not supported");
50
}
51
52
// Sanity testing that FRAME_POP works.
53
test("sanity", true, () -> {
54
setFramePopNotificationMode(true);
55
notifyFramePop(null);
56
});
57
58
// Request notification and then disable FRAME_POP event notification.
59
// This should not prevent the notification for the frame being cleared
60
// when we return from the method.
61
test("requestAndDisable", false, () -> {
62
setFramePopNotificationMode(true);
63
notifyFramePop(null);
64
setFramePopNotificationMode(false);
65
});
66
67
// Ensure there is no pending event
68
test("ensureCleared", false, () -> {
69
setFramePopNotificationMode(true);
70
});
71
72
log("Test PASSED");
73
}
74
75
private native static boolean canGenerateFramePopEvents();
76
private native static void setFramePopNotificationMode(boolean enabled);
77
private native static void notifyFramePop(Thread thread);
78
private native static boolean framePopReceived();
79
80
private static void log(String msg) {
81
System.out.println(msg);
82
}
83
84
private interface Test {
85
void test();
86
}
87
88
private static void test(String name, boolean framePopExpected, Test theTest) {
89
log("test: " + name);
90
theTest.test();
91
boolean actual = framePopReceived();
92
if (framePopExpected != actual) {
93
throw new RuntimeException("unexpected notification:"
94
+ " FramePop expected: " + (framePopExpected ? "yes" : "no")
95
+ ", actually received: " + (actual ? "yes" : "no"));
96
}
97
log(" - OK (" + (actual ? "received" : "NOT received") + ")");
98
}
99
100
}
101
102