History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/com/sun/jdi/Method.java (1 of 18352 files). Show all

Unified · Split

java/pkg/com/sun/jdi/Method.java+429−0
@@ -0,0 +1,429 @@
1/*
2 * Copyright (c) 1998, 2005, 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26package com.sun.jdi;
27
28import java.util.List;
29
30/**
31 * A static or instance method in the target VM. See {@link TypeComponent}
32 * for general information about Field and Method mirrors.
33 *
34 * @see ObjectReference
35 * @see ReferenceType
36 *
37 * @author Robert Field
38 * @author Gordon Hirsch
39 * @author James McIlree
40 * @since 1.3
41 */
42public interface Method extends TypeComponent, Locatable, Comparable<Method> {
43
44 /**
45 * Returns a text representation of the return type,
46 * as specified in the declaration of this method.
47 * <P>
48 * This type name is always available even if
49 * the type has not yet been created or loaded.
50 *
51 * @return a String containing the return type name.
52 */
53 String returnTypeName();
54
55 /**
56 * Returns the return type,
57 * as specified in the declaration of this method.
58 * <P>
59 * Note: if the return type of this method is a reference type (class,
60 * interface, or array) and it has not been created or loaded
61 * by the declaring type's class loader - that is,
62 * {@link TypeComponent#declaringType <CODE>declaringType()</CODE>}
63 * <CODE>.classLoader()</CODE>,
64 * then ClassNotLoadedException will be thrown.
65 * Also, a reference type may have been loaded but not yet prepared,
66 * in which case the type will be returned
67 * but attempts to perform some operations on the returned type
68 * (e.g. {@link ReferenceType#fields() fields()}) will throw
69 * a {@link ClassNotPreparedException}.
70 * Use {@link ReferenceType#isPrepared()} to determine if
71 * a reference type is prepared.
72 *
73 * @see Type
74 * @see Field#type() Field.type() - for usage examples
75 * @return the return {@link Type} of this method.
76 * @throws ClassNotLoadedException if the type has not yet been
77 * created or loaded
78 * through the appropriate class loader.
79 */
80 Type returnType() throws ClassNotLoadedException;
81
82 /**
83 * Returns a list containing a text representation of the type
84 * of each formal parameter of this method.
85 * <P>
86 * This list is always available even if
87 * the types have not yet been created or loaded.
88 *
89 * @return a {@link java.util.List List} of {@link String},
90 * one List element for each parameter of this method.
91 * Each element represents the type of a formal parameter
92 * as specified at compile-time.
93 * If the formal parameter was declared with an ellipsis, then
94 * it is represented as an array of the type before the ellipsis.
95 *
96 */
97 List<String> argumentTypeNames();
98
99 /**
100 * Returns a list containing the type
101 * of each formal parameter of this method.
102 * <P>
103 * Note: if there is any parameter whose type
104 * is a reference type (class, interface, or array)
105 * and it has not been created or loaded
106 * by the declaring type's class loader - that is,
107 * {@link TypeComponent#declaringType <CODE>declaringType()</CODE>}
108 * <CODE>.classLoader()</CODE>,
109 * then ClassNotLoadedException will be thrown.
110 * Also, a reference type may have been loaded but not yet prepared,
111 * in which case the list will be returned
112 * but attempts to perform some operations on the type
113 * (e.g. {@link ReferenceType#fields() fields()}) will throw
114 * a {@link ClassNotPreparedException}.
115 * Use {@link ReferenceType#isPrepared()} to determine if
116 * a reference type is prepared.
117 *
118 * @see Type
119 * @return return a {@link java.util.List List} of {@link Type},
120 * one List element for each parameter of this method.
121 * Each element represents the type of a formal parameter
122 * as specified at compile-time.
123 * If the formal parameter was declared with an ellipsis, then
124 * it is represented as an array of the type before the ellipsis.
125 *
126 * @throws ClassNotLoadedException if the type has not yet been loaded
127 * through the appropriate class loader.
128 */
129 List<Type> argumentTypes() throws ClassNotLoadedException;
130
131 /**
132 * Determine if this method is abstract.
133 *
134 * @return <code>true</code> if the method is declared abstract;
135 * false otherwise.
136 */
137 boolean isAbstract();
138
139 /**
140 * Determine if this method is synchronized.
141 *
142 * @return <code>true</code> if the method is declared synchronized;
143 * false otherwise.
144 */
145 boolean isSynchronized();
146
147 /**
148 * Determine if this method is native.
149 *
150 * @return <code>true</code> if the method is declared native;
151 * false otherwise.
152 */
153 boolean isNative();
154
155 /**
156 * Determine if this method accepts a variable number of arguments.
157 *
158 * @return <code>true</code> if the method accepts a variable number
159 * of arguments, false otherwise.
160 *
161 * @since 1.5
162 */
163 boolean isVarArgs();
164
165 /**
166 * Determine if this method is a bridge method. Bridge
167 * methods are defined in
168 * <cite>The Java&trade; Language Specification</cite>.
169 *
170 * @return <code>true</code> if the method is a bridge method,
171 * false otherwise.
172 *
173 * @since 1.5
174 */
175 boolean isBridge();
176
177 /**
178 * Determine if this method is a constructor.
179 *
180 * @return <code>true</code> if the method is a constructor;
181 * false otherwise.
182 */
183 boolean isConstructor();
184
185 /**
186 * Determine if this method is a static initializer.
187 *
188 * @return <code>true</code> if the method is a static initializer;
189 * false otherwise.
190 */
191 boolean isStaticInitializer();
192
193 /**
194 * Determine if this method is obsolete.
195 *
196 * @return <code>true</code> if this method has been made obsolete by a
197 * {@link VirtualMachine#redefineClasses} operation.
198 *
199 * @since 1.4
200 */
201 boolean isObsolete();
202
203 /**
204 * Returns a list containing a {@link Location} object for
205 * each executable source line in this method.
206 * <P>
207 * This method is equivalent to
208 * <code>allLineLocations(vm.getDefaultStratum(),null)</code> -
209 * see {@link #allLineLocations(String,String)}
210 * for more information.
211 *
212 * @return a List of all source line {@link Location} objects.
213 *
214 * @throws AbsentInformationException if there is no line
215 * number information for this (non-native, non-abstract)
216 * method.
217 */
218 List<Location> allLineLocations() throws AbsentInformationException;
219
220 /**
221 * Returns a list containing a {@link Location} object for
222 * each executable source line in this method.
223 * <P>
224 * Each location maps a source line to a range of code
225 * indices.
226 * The beginning of the range can be determined through
227 * {@link Location#codeIndex}.
228 * The returned list is ordered by code index
229 * (from low to high).
230 * <P>
231 * The returned list may contain multiple locations for a
232 * particular line number, if the compiler and/or VM has
233 * mapped that line to two or more disjoint code index ranges.
234 * <P>
235 * If the method is native or abstract, an empty list is
236 * returned.
237 * <P>
238 * Returned list is for the specified <i>stratum</i>
239 * (see {@link Location} for a description of strata).
240 *
241 * @param stratum The stratum to retrieve information from
242 * or <code>null</code> for the {@link ReferenceType#defaultStratum()}
243 *
244 * @param sourceName Return locations only within this
245 * source file or <code>null</code> to return locations.
246 *
247 * @return a List of all source line {@link Location} objects.
248 *
249 * @throws AbsentInformationException if there is no line
250 * number information for this (non-native, non-abstract)
251 * method. Or if <i>sourceName</i> is non-<code>null</code>
252 * and source name information is not present.
253 *
254 * @since 1.4
255 */
256 List<Location> allLineLocations(String stratum, String sourceName)
257 throws AbsentInformationException;
258
259 /**
260 * Returns a List containing all {@link Location} objects
261 * that map to the given line number.
262 * <P>
263 * This method is equivalent to
264 * <code>locationsOfLine(vm.getDefaultStratum(), null,
265 * lineNumber)</code> -
266 * see {@link
267 * #locationsOfLine(java.lang.String,java.lang.String,int)}
268 * for more information.
269 *
270 * @param lineNumber the line number
271 *
272 * @return a List of {@link Location} objects that map to
273 * the given line number.
274 *
275 * @throws AbsentInformationException if there is no line
276 * number information for this method.
277 */
278 List<Location> locationsOfLine(int lineNumber) throws AbsentInformationException;
279
280 /**
281 * Returns a List containing all {@link Location} objects
282 * that map to the given line number and source name.
283 * <P>
284 * Returns a list containing each {@link Location} that maps
285 * to the given line. The returned list will contain a
286 * location for each disjoint range of code indices that have
287 * been assigned to the given line by the compiler and/or
288 * VM. Each returned location corresponds to the beginning of
289 * this range. An empty list will be returned if there is no
290 * executable code at the specified line number; specifically,
291 * native and abstract methods will always return an empty
292 * list.
293 * <p>
294 * Returned list is for the specified <i>stratum</i>
295 * (see {@link Location} for a description of strata).
296 *
297 * @param stratum the stratum to use for comparing line number
298 * and source name, or null to use the default
299 * stratum
300 * @param sourceName the source name containing the
301 * line number, or null to match all
302 * source names
303 * @param lineNumber the line number
304 *
305 * @return a List of {@link Location} objects that map to
306 * the given line number.
307 *
308 * @throws AbsentInformationException if there is no line
309 * number information for this method.
310 * Or if <i>sourceName</i> is non-<code>null</code>
311 * and source name information is not present.
312 *
313 * @since 1.4
314 */
315 List<Location> locationsOfLine(String stratum, String sourceName,
316 int lineNumber)
317 throws AbsentInformationException;
318
319 /**
320 * Returns a {@link Location} for the given code index.
321 *
322 * @return the {@link Location} corresponding to the
323 * given code index or null if the specified code index is not a
324 * valid code index for this method (native and abstract methods
325 * will always return null).
326 */
327 Location locationOfCodeIndex(long codeIndex);
328
329 /**
330 * Returns a list containing each {@link LocalVariable} declared
331 * in this method. The list includes any variable declared in any
332 * scope within the method. It may contain multiple variables of the
333 * same name declared within disjoint scopes. Arguments are considered
334 * local variables and will be present in the returned list.
335 *
336 * If local variable information is not available, values of
337 * actual arguments to method invocations can be obtained
338 * by using the method {@link StackFrame#getArgumentValues()}
339 *
340 * @return the list of {@link LocalVariable} objects which mirror
341 * local variables declared in this method in the target VM.
342 * If there are no local variables, a zero-length list is returned.
343 * @throws AbsentInformationException if there is no variable
344 * information for this method.
345 * Generally, local variable information is not available for
346 * native or abstract methods (that is, their argument name
347 * information is not available), thus they will throw this exception.
348 */
349 List<LocalVariable> variables() throws AbsentInformationException;
350
351 /**
352 * Returns a list containing each {@link LocalVariable} of a
353 * given name in this method.
354 * Multiple variables can be returned
355 * if the same variable name is used in disjoint
356 * scopes within the method.
357 *
358 * @return the list of {@link LocalVariable} objects of the given
359 * name.
360 * If there are no matching local variables, a zero-length list
361 * is returned.
362 * @throws AbsentInformationException if there is no variable
363 * information for this method.
364 * Generally, local variable information is not available for
365 * native or abstract methods (that is, their argument name
366 * information is not available), thus they will throw this exception.
367 */
368 List<LocalVariable> variablesByName(String name)
369 throws AbsentInformationException;
370
371 /**
372 * Returns a list containing each {@link LocalVariable} that is
373 * declared as an argument of this method.
374 *
375 * If local variable information is not available, values of
376 * actual arguments to method invocations can be obtained
377 * by using the method {@link StackFrame#getArgumentValues()}
378 *
379 * @return the list of {@link LocalVariable} arguments.
380 * If there are no arguments, a zero-length list is returned.
381 * @throws AbsentInformationException if there is no variable
382 * information for this method.
383 * Generally, local variable information is not available for
384 * native or abstract methods (that is, their argument name
385 * information is not available), thus they will throw this exception.
386 */
387 List<LocalVariable> arguments() throws AbsentInformationException;
388
389 /**
390 * Returns an array containing the bytecodes for this method.
391 * <P>
392 * Not all target virtual machines support this operation.
393 * Use {@link VirtualMachine#canGetBytecodes()}
394 * to determine if the operation is supported.
395 *
396 * @return the array of bytecodes; abstract and native methods
397 * will return a zero-length array.
398 * @throws java.lang.UnsupportedOperationException if
399 * the target virtual machine does not support
400 * the retrieval of bytecodes.
401 */
402 byte[] bytecodes();
403
404 /**
405 * Returns the {@link Location} of this method, if there
406 * is executable code associated with it.
407 *
408 * @return the {@link Location} of this mirror, or null if
409 * this is an abstract method; native methods will return a
410 * Location object whose codeIndex is -1.
411 */
412 Location location();
413
414 /**
415 * Compares the specified Object with this method for equality.
416 *
417 * @return true if the Object is a method and if both
418 * mirror the same method (declared in the same class or interface, in
419 * the same VM).
420 */
421 boolean equals(Object obj);
422
423 /**
424 * Returns the hash code value for this Method.
425 *
426 * @return the integer hash code
427 */
428 int hashCode();
429}