Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/com/sun/jdi/ArrayLengthDumpTest.java
41149 views
1
/*
2
* Copyright (c) 2002, 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 4422141 4695338
27
* @summary TTY: .length field for arrays in print statements in jdb not recognized
28
* TTY: dump <ArrayReference> command not implemented.
29
* @comment converted from test/jdk/com/sun/jdi/ArrayLengthDumpTest.sh
30
*
31
* @library /test/lib
32
* @build ArrayLengthDumpTest
33
* @run main/othervm ArrayLengthDumpTest
34
*/
35
36
import lib.jdb.JdbCommand;
37
import lib.jdb.JdbTest;
38
import jdk.test.lib.process.OutputAnalyzer;
39
40
import java.util.LinkedList;
41
import java.util.List;
42
import java.util.stream.Collectors;
43
44
45
class ArrayLengthDumpTarg {
46
static final int [] i = {0,1,2,3,4,5,6};
47
String [] s = {"zero", "one", "two", "three", "four"};
48
String [][] t = {s, s, s, s, s, s, s, s, s, s, s};
49
int length = 5;
50
51
private void bar() {
52
}
53
54
private void foo() {
55
ArrayLengthDumpTarg u[] = { new ArrayLengthDumpTarg(),
56
new ArrayLengthDumpTarg(),
57
new ArrayLengthDumpTarg(),
58
new ArrayLengthDumpTarg(),
59
new ArrayLengthDumpTarg(),
60
new ArrayLengthDumpTarg() };
61
int k = u.length;
62
System.out.println(" u.length is: " + k);
63
k = this.s.length;
64
System.out.println(" this.s.length is: " + k);
65
k = this.t.length;
66
System.out.println(" this.t.length is: " + k);
67
k = this.t[1].length;
68
System.out.println("this.t[1].length is: " + k);
69
k = i.length;
70
System.out.println(" i.length is: " + k);
71
bar(); // @1 breakpoint
72
}
73
74
public static void main(String[] args) {
75
ArrayLengthDumpTarg my = new ArrayLengthDumpTarg();
76
my.foo();
77
}
78
}
79
80
public class ArrayLengthDumpTest extends JdbTest {
81
public static void main(String argv[]) {
82
new ArrayLengthDumpTest().run();
83
}
84
85
public ArrayLengthDumpTest() {
86
super(DEBUGGEE_CLASS);
87
}
88
89
private static final String DEBUGGEE_CLASS = ArrayLengthDumpTarg.class.getName();
90
91
@Override
92
protected void runCases() {
93
setBreakpointsFromTestSource("ArrayLengthDumpTest.java", 1);
94
95
// Run to breakpoint #1
96
jdb.command(JdbCommand.run());
97
98
List<String> reply = new LinkedList<>();
99
reply.addAll(jdb.command(JdbCommand.dump("this")));
100
reply.addAll(jdb.command(JdbCommand.dump("this.s.length")));
101
reply.addAll(jdb.command(JdbCommand.dump("this.s")));
102
reply.addAll(jdb.command(JdbCommand.dump("this.t.length")));
103
reply.addAll(jdb.command(JdbCommand.dump("this.t[1].length")));
104
reply.addAll(jdb.command(JdbCommand.dump("ArrayLengthDumpTarg.i.length")));
105
reply.addAll(jdb.command(JdbCommand.dump("this.length")));
106
107
new OutputAnalyzer(reply.stream().collect(Collectors.joining(lineSeparator)))
108
// Test the fix for 4690242:
109
.shouldNotContain("No instance field or method with the name length in")
110
.shouldNotContain("No static field or method with the name length")
111
// Test the fix for 4695338:
112
.shouldContain("\"zero\", \"one\", \"two\", \"three\", \"four\"");
113
114
jdb.contToExit(1);
115
}
116
117
}
118
119