J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright 1998-2004 Sun Microsystems, Inc. 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. Sun designates this |
| 8 | * particular file as subject to the "Classpath" exception as provided |
| 9 | * by Sun 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 22 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 23 | * have any questions. |
| 24 | */ |
| 25 | |
| 26 | package com.sun.jdi; |
| 27 | |
| 28 | /** |
| 29 | * A local variable in the target VM. Each variable declared within a |
| 30 | * {@link Method} has its own LocalVariable object. Variables of the same |
| 31 | * name declared in different scopes have different LocalVariable objects. |
| 32 | * LocalVariables can be used alone to retrieve static information |
| 33 | * about their declaration, or can be used in conjunction with a |
| 34 | * {@link StackFrame} to set and get values. |
| 35 | * |
| 36 | * @see StackFrame |
| 37 | * @see Method |
| 38 | * |
| 39 | * @author Robert Field |
| 40 | * @author Gordon Hirsch |
| 41 | * @author James McIlree |
| 42 | * @since 1.3 |
| 43 | */ |
| 44 | |
| 45 | public interface LocalVariable extends Mirror, Comparable<LocalVariable> { |
| 46 | |
| 47 | /** |
| 48 | * Gets the name of the local variable. |
| 49 | * |
| 50 | * @return a string containing the name. |
| 51 | */ |
| 52 | String name(); |
| 53 | |
| 54 | /** |
| 55 | * Returns a text representation of the type |
| 56 | * of this variable. |
| 57 | * Where the type is the type specified in the declaration |
| 58 | * of this local variable. |
| 59 | * <P> |
| 60 | * This type name is always available even if |
| 61 | * the type has not yet been created or loaded. |
| 62 | * |
| 63 | * @return a String representing the |
| 64 | * type of this local variable. |
| 65 | |
| 66 | */ |
| 67 | String typeName(); |
| 68 | |
| 69 | /** |
| 70 | * Returns the type of this variable. |
| 71 | * Where the type is the type specified in the declaration |
| 72 | * of this local variable. |
| 73 | * <P> |
| 74 | * Note: if the type of this variable is a reference type (class, |
| 75 | * interface, or array) and it has not been created or loaded |
| 76 | * by the class loader of the enclosing class, |
| 77 | * then ClassNotLoadedException will be thrown. |
| 78 | * Also, a reference type may have been loaded but not yet prepared, |
| 79 | * in which case the type will be returned |
| 80 | * but attempts to perform some operations on the returned type |
| 81 | * (e.g. {@link ReferenceType#fields() fields()}) will throw |
| 82 | * a {@link ClassNotPreparedException}. |
| 83 | * Use {@link ReferenceType#isPrepared()} to determine if |
| 84 | * a reference type is prepared. |
| 85 | * |
| 86 | * @see Type |
| 87 | * @see Field#type() Field.type() - for usage examples |
| 88 | * @return the {@link Type} of this local variable. |
| 89 | * @throws ClassNotLoadedException if the type has not yet been loaded |
| 90 | * through the appropriate class loader. |
| 91 | */ |
| 92 | Type type() throws ClassNotLoadedException; |
| 93 | |
| 94 | /** |
| 95 | * Gets the JNI signature of the local variable. |
| 96 | * |
| 97 | * @see <a href="doc-files/signature.html">Type Signatures</a> |
| 98 | * @return a string containing the signature. |
| 99 | */ |
| 100 | String signature(); |
| 101 | |
| 102 | /** |
| 103 | * Gets the generic signature for this variable if there is one. |
| 104 | * Generic signatures are described in the |
| 105 | * <a href="http://java.sun.com/docs/books/vmspec"> |
| 106 | * "Java<sup><font size=-2>TM</font></sup> |
| 107 | * Virtual Machine Specification, 3rd Edition.</a> |
| 108 | * |
| 109 | * @return a string containing the generic signature, or <code>null</code> |
| 110 | * if there is no generic signature. |
| 111 | * |
| 112 | * @since 1.5 |
| 113 | */ |
| 114 | String genericSignature(); |
| 115 | |
| 116 | /** |
| 117 | * Determines whether this variable can be accessed from the given |
| 118 | * {@link StackFrame}. |
| 119 | * |
| 120 | * See {@link StackFrame#visibleVariables} for a complete description |
| 121 | * variable visibility in this interface. |
| 122 | * |
| 123 | * @param frame the StackFrame querying visibility |
| 124 | * @return <code>true</code> if this variable is visible; |
| 125 | * <code>false</code> otherwise. |
| 126 | * @throws IllegalArgumentException if the stack frame's method |
| 127 | * does not match this variable's method. |
| 128 | */ |
| 129 | boolean isVisible(StackFrame frame); |
| 130 | |
| 131 | /** |
| 132 | * Determines if this variable is an argument to its method. |
| 133 | * |
| 134 | * @return <code>true</code> if this variable is an argument; |
| 135 | * <code>false</code> otherwise. |
| 136 | */ |
| 137 | boolean isArgument(); |
| 138 | |
| 139 | /** |
| 140 | * Compares the specified Object with this LocalVariable for equality. |
| 141 | * |
| 142 | * @return true if the Object is a LocalVariable, if both LocalVariables |
| 143 | * are contained in the same method (as determined by |
| 144 | * {@link Method#equals}), and if both LocalVariables mirror |
| 145 | * the same declaration within that method |
| 146 | */ |
| 147 | boolean equals(Object obj); |
| 148 | |
| 149 | /** |
| 150 | * Returns the hash code value for this LocalVariable. |
| 151 | * |
| 152 | * @return the integer hash code |
| 153 | */ |
| 154 | int hashCode(); |
| 155 | } |