Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jdi/BreakpointWithFullGC.java
41152 views
1
/*
2
* Copyright (c) 2009, 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
* @bug 6862295
27
* @summary Verify breakpoints still work after a full GC.
28
* @comment converted from test/jdk/com/sun/jdi/BreakpointWithFullGC.sh
29
*
30
* @library /test/lib
31
* @compile -g BreakpointWithFullGC.java
32
* @run main/othervm BreakpointWithFullGC
33
*/
34
35
import jdk.test.lib.process.OutputAnalyzer;
36
import lib.jdb.Jdb;
37
import lib.jdb.JdbCommand;
38
import lib.jdb.JdbTest;
39
40
import java.util.ArrayList;
41
import java.util.List;
42
43
class BreakpointWithFullGCTarg {
44
public static List<Object> objList = new ArrayList<>();
45
46
private static void init(int numObjs) {
47
for (int i = 0; i < numObjs; i++) {
48
objList.add(new Object());
49
}
50
}
51
52
public static void main(String[] args) {
53
for (int i = 0; i < 10; i++) {
54
System.out.println("top of loop"); // @1 breakpoint
55
init(500000);
56
objList.clear();
57
System.gc();
58
System.out.println("bottom of loop"); // @1 breakpoint
59
}
60
System.out.println("end of test"); // @1 breakpoint
61
}
62
}
63
64
public class BreakpointWithFullGC extends JdbTest {
65
public static void main(String argv[]) {
66
new BreakpointWithFullGC().run();
67
}
68
69
private BreakpointWithFullGC() {
70
super(new LaunchOptions(DEBUGGEE_CLASS)
71
.addDebuggeeOptions(DEBUGGEE_OPTIONS));
72
}
73
74
private static final String DEBUGGEE_CLASS = BreakpointWithFullGCTarg.class.getName();
75
// We don't specify "-Xmx" for debuggee as we have full GCs with any value.
76
private static final String[] DEBUGGEE_OPTIONS = {"-verbose:gc"};
77
78
@Override
79
protected void runCases() {
80
setBreakpointsFromTestSource("BreakpointWithFullGC.java", 1);
81
82
// get to the first loop breakpoint
83
jdb.command(JdbCommand.run());
84
// 19 "cont" commands gets us through all the loop breakpoints.
85
for (int i = 1; i <= 19; i++) {
86
jdb.command(JdbCommand.cont());
87
}
88
// get to the last breakpoint
89
jdb.command(JdbCommand.cont());
90
91
jdb.contToExit(1);
92
93
new OutputAnalyzer(getJdbOutput())
94
// make sure we hit the first breakpoint at least once
95
.stdoutShouldMatch("System\\..*top of loop")
96
// make sure we hit the second breakpoint at least once
97
.stdoutShouldMatch("System\\..*bottom of loop")
98
// make sure we hit the last breakpoint
99
.stdoutShouldMatch("System\\..*end of test");
100
new OutputAnalyzer(getDebuggeeOutput())
101
// check for error message due to thread ID change
102
.stderrShouldNotContain("Exception in thread \"event-handler\" java.lang.NullPointerException");
103
}
104
}
105
106