author | sla |
Fri, 29 May 2015 11:05:52 +0200 | |
changeset 30964 | 613fbce96e32 |
parent 30376 | 2ccf2cf7ea48 |
child 44423 | 306c020eb154 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
30376
2ccf2cf7ea48
8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents:
24973
diff
changeset
|
2 |
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
* |
|
5506 | 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. |
|
2 | 22 |
*/ |
23 |
||
24 |
/** |
|
25 |
* @test |
|
26 |
* @bug 4248728 |
|
27 |
* @summary Test ReferenceType.allLineLocations |
|
28 |
* @author Gordon Hirsch |
|
29 |
* |
|
30376
2ccf2cf7ea48
8078896: Add @modules as needed to the jdk_svc tests
ykantser
parents:
24973
diff
changeset
|
30 |
* @modules jdk.jdi |
2 | 31 |
* @run build JDIScaffold VMConnection |
32 |
* @run compile -g RefTypes.java |
|
33 |
* @run build AllLineLocations |
|
34 |
* |
|
24973
8c4bc3fa4c4e
6622468: TEST_BUG: Time to retire the @debuggeeVMOptions mechanism used in the com.sun.jdi infrastructure
sla
parents:
5506
diff
changeset
|
35 |
* @run driver AllLineLocations RefTypes |
2 | 36 |
*/ |
37 |
import com.sun.jdi.*; |
|
38 |
import com.sun.jdi.event.*; |
|
39 |
import com.sun.jdi.request.*; |
|
40 |
||
41 |
import java.util.List; |
|
42 |
||
43 |
public class AllLineLocations extends JDIScaffold { |
|
44 |
final String[] args; |
|
45 |
||
46 |
public static void main(String args[]) throws Exception { |
|
47 |
new AllLineLocations(args).startTests(); |
|
48 |
} |
|
49 |
||
50 |
AllLineLocations(String args[]) { |
|
51 |
super(); |
|
52 |
this.args = args; |
|
53 |
} |
|
54 |
||
55 |
protected void runTests() throws Exception { |
|
56 |
connect(args); |
|
57 |
waitForVMStart(); |
|
58 |
||
59 |
/* |
|
60 |
* Get to a point where the classes are loaded. |
|
61 |
*/ |
|
62 |
BreakpointEvent bp = resumeTo("RefTypes", "loadClasses", "()V"); |
|
63 |
stepOut(bp.thread()); |
|
64 |
||
65 |
/* |
|
66 |
* These classes should have no line numbers, except for |
|
67 |
* one in the implicit constructor. |
|
68 |
*/ |
|
69 |
ReferenceType rt = findReferenceType("AllAbstract"); |
|
70 |
if (rt == null) { |
|
71 |
throw new Exception("AllAbstract: not loaded"); |
|
72 |
} |
|
73 |
List list = rt.allLineLocations(); |
|
74 |
if (list.size() != 1) { |
|
75 |
throw new Exception("AllAbstract: incorrect number of line locations"); |
|
76 |
} |
|
77 |
if (rt.locationsOfLine(5000).size() != 0) { |
|
78 |
throw new Exception("AllAbstract: incorrect locationsOfLine"); |
|
79 |
} |
|
80 |
Method method = findMethod(rt, "<init>", "()V"); |
|
81 |
if (method == null) { |
|
82 |
throw new Exception("AllAbstract.<init> not found"); |
|
83 |
} |
|
84 |
List list2 = method.allLineLocations(); |
|
85 |
if (!list2.equals(list)) { |
|
86 |
throw new Exception("AllAbstract: line locations in wrong method"); |
|
87 |
} |
|
88 |
if (method.locationsOfLine(5000).size() != 0) { |
|
89 |
throw new Exception("AllAbstract: incorrect locationsOfLine"); |
|
90 |
} |
|
91 |
System.out.println("AllAbstract: passed"); |
|
92 |
||
93 |
rt = findReferenceType("AllNative"); |
|
94 |
if (rt == null) { |
|
95 |
throw new Exception("AllNative: not loaded"); |
|
96 |
} |
|
97 |
list = rt.allLineLocations(); |
|
98 |
if (list.size() != 1) { |
|
99 |
throw new Exception("AllNative: incorrect number of line locations"); |
|
100 |
} |
|
101 |
if (rt.locationsOfLine(5000).size() != 0) { |
|
102 |
throw new Exception("AllNative: incorrect locationsOfLine"); |
|
103 |
} |
|
104 |
method = findMethod(rt, "<init>", "()V"); |
|
105 |
if (method == null) { |
|
106 |
throw new Exception("AllNative.<init> not found"); |
|
107 |
} |
|
108 |
list2 = method.allLineLocations(); |
|
109 |
if (!list2.equals(list)) { |
|
110 |
throw new Exception("AllNative: line locations in wrong method"); |
|
111 |
} |
|
112 |
if (method.locationsOfLine(5000).size() != 0) { |
|
113 |
throw new Exception("AllNative: incorrect locationsOfLine"); |
|
114 |
} |
|
115 |
System.out.println("AllNative: passed"); |
|
116 |
||
117 |
rt = findReferenceType("Interface"); |
|
118 |
if (rt == null) { |
|
119 |
throw new Exception("Interface: not loaded"); |
|
120 |
} |
|
121 |
list = rt.allLineLocations(); |
|
122 |
if (list.size() != 0) { |
|
123 |
throw new Exception("Interface: locations reported for abstract methods"); |
|
124 |
} |
|
125 |
System.out.println("Interface: passed"); |
|
126 |
||
127 |
/* |
|
128 |
* These classes have line numbers in one method and |
|
129 |
* in the implicit constructor. |
|
130 |
*/ |
|
131 |
rt = findReferenceType("Abstract"); |
|
132 |
if (rt == null) { |
|
133 |
throw new Exception("Abstract: not loaded"); |
|
134 |
} |
|
135 |
list = rt.allLineLocations(); |
|
136 |
if (list.size() != 5) { |
|
137 |
throw new Exception("Abstract: incorrect number of line locations"); |
|
138 |
} |
|
139 |
method = findMethod(rt, "b", "()V"); |
|
140 |
if (method == null) { |
|
141 |
throw new Exception("Abstract.b not found"); |
|
142 |
} |
|
143 |
list2 = method.allLineLocations(); |
|
144 |
list.removeAll(list2); |
|
145 |
||
146 |
// Remaining location should be in constructor |
|
147 |
if ((list.size() != 1) || |
|
148 |
!(((Location)list.get(0)).method().name().equals("<init>"))) { |
|
149 |
throw new Exception("Abstract: line locations in wrong method"); |
|
150 |
} |
|
151 |
if (method.locationsOfLine(20).size() != 1) { |
|
152 |
throw new Exception("Abstract method: incorrect locationsOfLine"); |
|
153 |
} |
|
154 |
if (method.locationsOfLine(5000).size() != 0) { |
|
155 |
throw new Exception("Abstract method: incorrect locationsOfLine"); |
|
156 |
} |
|
157 |
method = findMethod(rt, "a", "()V"); |
|
158 |
if (method.locationsOfLine(5000).size() != 0) { |
|
159 |
throw new Exception("Abstract method: incorrect locationsOfLine"); |
|
160 |
} |
|
161 |
System.out.println("Abstract: passed"); |
|
162 |
||
163 |
rt = findReferenceType("Native"); |
|
164 |
if (rt == null) { |
|
165 |
throw new Exception("Native: not loaded"); |
|
166 |
} |
|
167 |
list = rt.allLineLocations(); |
|
168 |
if (list.size() != 5) { |
|
169 |
throw new Exception("Native: incorrect number of line locations"); |
|
170 |
} |
|
171 |
if (rt.locationsOfLine(5000).size() != 0) { |
|
172 |
throw new Exception("Native: incorrect locationsOfLine"); |
|
173 |
} |
|
174 |
method = findMethod(rt, "b", "()V"); |
|
175 |
if (method == null) { |
|
176 |
throw new Exception("Native.b not found"); |
|
177 |
} |
|
178 |
list2 = method.allLineLocations(); |
|
179 |
list.removeAll(list2); |
|
180 |
||
181 |
// Remaining location should be in constructor |
|
182 |
if ((list.size() != 1) || |
|
183 |
!(((Location)list.get(0)).method().name().equals("<init>"))) { |
|
184 |
throw new Exception("Native: line locations in wrong method"); |
|
185 |
} |
|
186 |
if (method.locationsOfLine(30).size() != 1) { |
|
187 |
throw new Exception("Native method: incorrect locationsOfLine"); |
|
188 |
} |
|
189 |
if (method.locationsOfLine(5000).size() != 0) { |
|
190 |
throw new Exception("Native method: incorrect locationsOfLine"); |
|
191 |
} |
|
192 |
method = findMethod(rt, "a", "()V"); |
|
193 |
if (method.locationsOfLine(5000).size() != 0) { |
|
194 |
throw new Exception("Native method: incorrect locationsOfLine"); |
|
195 |
} |
|
196 |
System.out.println("Native: passed"); |
|
197 |
||
198 |
rt = findReferenceType("AbstractAndNative"); |
|
199 |
if (rt == null) { |
|
200 |
throw new Exception("AbstractAndNative: not loaded"); |
|
201 |
} |
|
202 |
list = rt.allLineLocations(); |
|
203 |
if (list.size() != 5) { |
|
204 |
throw new Exception("AbstractAndNative: incorrect number of line locations"); |
|
205 |
} |
|
206 |
if (rt.locationsOfLine(5000).size() != 0) { |
|
207 |
throw new Exception("AbstractAndNative: incorrect locationsOfLine"); |
|
208 |
} |
|
209 |
method = findMethod(rt, "c", "()V"); |
|
210 |
if (method == null) { |
|
211 |
throw new Exception("AbstractAndNative.c not found"); |
|
212 |
} |
|
213 |
list2 = method.allLineLocations(); |
|
214 |
list.removeAll(list2); |
|
215 |
||
216 |
// Remaining location should be in constructor |
|
217 |
if ((list.size() != 1) || |
|
218 |
!(((Location)list.get(0)).method().name().equals("<init>"))) { |
|
219 |
throw new Exception("AbstractAndNative: line locations in wrong method"); |
|
220 |
} |
|
221 |
System.out.println("AbstractAndNative: passed"); |
|
222 |
||
223 |
// Allow application to complete |
|
224 |
resumeToVMDeath(); |
|
225 |
} |
|
226 |
} |