1 /* 2 * Copyright (c) 1998, 2013, 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 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 @jdk.Exported 46 public interface LocalVariable extends Mirror, Comparable<LocalVariable> { 47 48 /** 49 * Gets the name of the local variable. 50 * 51 * @return a string containing the name. 52 */ name()53 String name(); 54 55 /** 56 * Returns a text representation of the type 57 * of this variable. 58 * Where the type is the type specified in the declaration 59 * of this local variable. 60 * <P> 61 * This type name is always available even if 62 * the type has not yet been created or loaded. 63 * 64 * @return a String representing the 65 * type of this local variable. 66 67 */ typeName()68 String typeName(); 69 70 /** 71 * Returns the type of this variable. 72 * Where the type is the type specified in the declaration 73 * of this local variable. 74 * <P> 75 * Note: if the type of this variable is a reference type (class, 76 * interface, or array) and it has not been created or loaded 77 * by the class loader of the enclosing class, 78 * then ClassNotLoadedException will be thrown. 79 * Also, a reference type may have been loaded but not yet prepared, 80 * in which case the type will be returned 81 * but attempts to perform some operations on the returned type 82 * (e.g. {@link ReferenceType#fields() fields()}) will throw 83 * a {@link ClassNotPreparedException}. 84 * Use {@link ReferenceType#isPrepared()} to determine if 85 * a reference type is prepared. 86 * 87 * @see Type 88 * @see Field#type() Field.type() - for usage examples 89 * @return the {@link Type} of this local variable. 90 * @throws ClassNotLoadedException if the type has not yet been loaded 91 * through the appropriate class loader. 92 */ type()93 Type type() throws ClassNotLoadedException; 94 95 /** 96 * Gets the JNI signature of the local variable. 97 * 98 * @see <a href="doc-files/signature.html">Type Signatures</a> 99 * @return a string containing the signature. 100 */ signature()101 String signature(); 102 103 /** 104 * Gets the generic signature for this variable if there is one. 105 * Generic signatures are described in the 106 * <cite>The Java™ Virtual Machine Specification</cite>. 107 * 108 * @return a string containing the generic signature, or <code>null</code> 109 * if there is no generic signature. 110 * 111 * @since 1.5 112 */ genericSignature()113 String genericSignature(); 114 115 /** 116 * Determines whether this variable can be accessed from the given 117 * {@link StackFrame}. 118 * 119 * See {@link StackFrame#visibleVariables} for a complete description 120 * variable visibility in this interface. 121 * 122 * @param frame the StackFrame querying visibility 123 * @return <code>true</code> if this variable is visible; 124 * <code>false</code> otherwise. 125 * @throws IllegalArgumentException if the stack frame's method 126 * does not match this variable's method. 127 */ isVisible(StackFrame frame)128 boolean isVisible(StackFrame frame); 129 130 /** 131 * Determines if this variable is an argument to its method. 132 * 133 * @return <code>true</code> if this variable is an argument; 134 * <code>false</code> otherwise. 135 */ isArgument()136 boolean isArgument(); 137 138 /** 139 * Compares the specified Object with this LocalVariable for equality. 140 * 141 * @return true if the Object is a LocalVariable, if both LocalVariables 142 * are contained in the same method (as determined by 143 * {@link Method#equals}), and if both LocalVariables mirror 144 * the same declaration within that method 145 */ equals(Object obj)146 boolean equals(Object obj); 147 148 /** 149 * Returns the hash code value for this LocalVariable. 150 * 151 * @return the integer hash code 152 */ hashCode()153 int hashCode(); 154 } 155