annotate agent/src/share/classes/sun/jvm/hotspot/jdi/StackFrameImpl.java @ 1552:c18cbe5936b8

6941466: Oracle rebranding changes for Hotspot repositories Summary: Change all the Sun copyrights to Oracle copyright Reviewed-by: ohair
author trims
date Thu, 27 May 2010 19:08:38 -0700
parents a61af66fc99e
children 7588156f5cf9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 2002, 2005, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.jdi;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import com.sun.jdi.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import sun.jvm.hotspot.oops.ObjectHeap;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.debugger.OopHandle;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.oops.Array;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.oops.ObjArray;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.oops.TypeArray;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.oops.Instance;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.runtime.BasicType;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 import sun.jvm.hotspot.runtime.JavaVFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
36 import sun.jvm.hotspot.runtime.StackValue;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 import sun.jvm.hotspot.runtime.StackValueCollection;
a61af66fc99e Initial load
duke
parents:
diff changeset
38 import sun.jvm.hotspot.utilities.Assert;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 import java.util.List;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 import java.util.Map;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 import java.util.ArrayList;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 import java.util.HashMap;
a61af66fc99e Initial load
duke
parents:
diff changeset
43 import java.util.Iterator;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 import java.util.Collections;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public class StackFrameImpl extends MirrorImpl
a61af66fc99e Initial load
duke
parents:
diff changeset
47 implements StackFrame
a61af66fc99e Initial load
duke
parents:
diff changeset
48 {
a61af66fc99e Initial load
duke
parents:
diff changeset
49 /* Once false, frame should not be used.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 * access synchronized on (vm.state())
a61af66fc99e Initial load
duke
parents:
diff changeset
51 */
a61af66fc99e Initial load
duke
parents:
diff changeset
52 private boolean isValid = true;
a61af66fc99e Initial load
duke
parents:
diff changeset
53
a61af66fc99e Initial load
duke
parents:
diff changeset
54 private final ThreadReferenceImpl thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private final JavaVFrame saFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 private final Location location;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 private Map visibleVariables = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
58 private ObjectReference thisObject = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 StackFrameImpl(VirtualMachine vm, ThreadReferenceImpl thread,
a61af66fc99e Initial load
duke
parents:
diff changeset
61 JavaVFrame jvf) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 super(vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 this.thread = thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 this.saFrame = jvf;
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 sun.jvm.hotspot.oops.Method SAMethod = jvf.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 ReferenceType rt = ((VirtualMachineImpl)vm).referenceType(SAMethod.getMethodHolder());
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 this.location = new LocationImpl(vm, rt, SAMethod, (long)jvf.getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
71 }
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 private void validateStackFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 if (!isValid) {
a61af66fc99e Initial load
duke
parents:
diff changeset
75 throw new InvalidStackFrameException("Thread has been resumed");
a61af66fc99e Initial load
duke
parents:
diff changeset
76 }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 JavaVFrame getJavaVFrame() {
a61af66fc99e Initial load
duke
parents:
diff changeset
80 return saFrame;
a61af66fc99e Initial load
duke
parents:
diff changeset
81 }
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
84 * Return the frame location.
a61af66fc99e Initial load
duke
parents:
diff changeset
85 * Need not be synchronized since it cannot be provably stale.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 */
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public Location location() {
a61af66fc99e Initial load
duke
parents:
diff changeset
88 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
89 return location;
a61af66fc99e Initial load
duke
parents:
diff changeset
90 }
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
93 * Return the thread holding the frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
94 * Need not be synchronized since it cannot be provably stale.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 */
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public ThreadReference thread() {
a61af66fc99e Initial load
duke
parents:
diff changeset
97 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
98 return thread;
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public boolean equals(Object obj) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if ((obj != null) && (obj instanceof StackFrameImpl)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 StackFrameImpl other = (StackFrameImpl)obj;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 return (saFrame.equals(other.saFrame));
a61af66fc99e Initial load
duke
parents:
diff changeset
105 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
106 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
107 }
a61af66fc99e Initial load
duke
parents:
diff changeset
108 }
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 public int hashCode() {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 return saFrame.hashCode();
a61af66fc99e Initial load
duke
parents:
diff changeset
112 }
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 public ObjectReference thisObject() {
a61af66fc99e Initial load
duke
parents:
diff changeset
115 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
116 MethodImpl currentMethod = (MethodImpl)location.method();
a61af66fc99e Initial load
duke
parents:
diff changeset
117 if (currentMethod.isStatic() || currentMethod.isNative()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
118 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 if (thisObject == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
121 StackValueCollection values = saFrame.getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
122 if (Assert.ASSERTS_ENABLED) {
a61af66fc99e Initial load
duke
parents:
diff changeset
123 Assert.that(values.size() > 0, "this is missing");
a61af66fc99e Initial load
duke
parents:
diff changeset
124 }
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // 'this' at index 0.
a61af66fc99e Initial load
duke
parents:
diff changeset
126 OopHandle handle = values.oopHandleAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 ObjectHeap heap = vm.saObjectHeap();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 thisObject = vm.objectMirror(heap.newOop(handle));
a61af66fc99e Initial load
duke
parents:
diff changeset
129 }
a61af66fc99e Initial load
duke
parents:
diff changeset
130 return thisObject;
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
134 * Build the visible variable map.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 * Need not be synchronized since it cannot be provably stale.
a61af66fc99e Initial load
duke
parents:
diff changeset
136 */
a61af66fc99e Initial load
duke
parents:
diff changeset
137 private void createVisibleVariables() throws AbsentInformationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if (visibleVariables == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
139 List allVariables = location.method().variables();
a61af66fc99e Initial load
duke
parents:
diff changeset
140 Map map = new HashMap(allVariables.size());
a61af66fc99e Initial load
duke
parents:
diff changeset
141
a61af66fc99e Initial load
duke
parents:
diff changeset
142 Iterator iter = allVariables.iterator();
a61af66fc99e Initial load
duke
parents:
diff changeset
143 while (iter.hasNext()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
144 LocalVariableImpl variable = (LocalVariableImpl)iter.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
145 String name = variable.name();
a61af66fc99e Initial load
duke
parents:
diff changeset
146 if (variable.isVisible(this)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 LocalVariable existing = (LocalVariable)map.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
148 if ((existing == null) ||
a61af66fc99e Initial load
duke
parents:
diff changeset
149 variable.hides(existing)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 map.put(name, variable);
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152 }
a61af66fc99e Initial load
duke
parents:
diff changeset
153 }
a61af66fc99e Initial load
duke
parents:
diff changeset
154 visibleVariables = map;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
159 * Return the list of visible variable in the frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
160 * Need not be synchronized since it cannot be provably stale.
a61af66fc99e Initial load
duke
parents:
diff changeset
161 */
a61af66fc99e Initial load
duke
parents:
diff changeset
162 public List visibleVariables() throws AbsentInformationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
164 createVisibleVariables();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 List mapAsList = new ArrayList(visibleVariables.values());
a61af66fc99e Initial load
duke
parents:
diff changeset
166 Collections.sort(mapAsList);
a61af66fc99e Initial load
duke
parents:
diff changeset
167 return mapAsList;
a61af66fc99e Initial load
duke
parents:
diff changeset
168 }
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 /**
a61af66fc99e Initial load
duke
parents:
diff changeset
171 * Return a particular variable in the frame.
a61af66fc99e Initial load
duke
parents:
diff changeset
172 * Need not be synchronized since it cannot be provably stale.
a61af66fc99e Initial load
duke
parents:
diff changeset
173 */
a61af66fc99e Initial load
duke
parents:
diff changeset
174 public LocalVariable visibleVariableByName(String name) throws AbsentInformationException {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
176 createVisibleVariables();
a61af66fc99e Initial load
duke
parents:
diff changeset
177 return (LocalVariable)visibleVariables.get(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
178 }
a61af66fc99e Initial load
duke
parents:
diff changeset
179
a61af66fc99e Initial load
duke
parents:
diff changeset
180 public Value getValue(LocalVariable variable) {
a61af66fc99e Initial load
duke
parents:
diff changeset
181 List list = new ArrayList(1);
a61af66fc99e Initial load
duke
parents:
diff changeset
182 list.add(variable);
a61af66fc99e Initial load
duke
parents:
diff changeset
183 Map map = getValues(list);
a61af66fc99e Initial load
duke
parents:
diff changeset
184 return (Value)map.get(variable);
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186
a61af66fc99e Initial load
duke
parents:
diff changeset
187 public Map getValues(List variables) {
a61af66fc99e Initial load
duke
parents:
diff changeset
188 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
189 StackValueCollection values = saFrame.getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 int count = variables.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
192 Map map = new HashMap(count);
a61af66fc99e Initial load
duke
parents:
diff changeset
193 for (int ii=0; ii<count; ++ii) {
a61af66fc99e Initial load
duke
parents:
diff changeset
194 LocalVariableImpl variable = (LocalVariableImpl)variables.get(ii);
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if (!variable.isVisible(this)) {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 throw new IllegalArgumentException(variable.name() +
a61af66fc99e Initial load
duke
parents:
diff changeset
197 " is not valid at this frame location");
a61af66fc99e Initial load
duke
parents:
diff changeset
198 }
a61af66fc99e Initial load
duke
parents:
diff changeset
199 ValueImpl valueImpl;
a61af66fc99e Initial load
duke
parents:
diff changeset
200 int ss = variable.slot();
a61af66fc99e Initial load
duke
parents:
diff changeset
201 char c = variable.signature().charAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 BasicType variableType = BasicType.charToBasicType(c);
a61af66fc99e Initial load
duke
parents:
diff changeset
203 valueImpl = getSlotValue(values, variableType, ss);
a61af66fc99e Initial load
duke
parents:
diff changeset
204 map.put(variable, valueImpl);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 return map;
a61af66fc99e Initial load
duke
parents:
diff changeset
207 }
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 public List getArgumentValues() {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 validateStackFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
211 StackValueCollection values = saFrame.getLocals();
a61af66fc99e Initial load
duke
parents:
diff changeset
212 MethodImpl mmm = (MethodImpl)location.method();
a61af66fc99e Initial load
duke
parents:
diff changeset
213 List argSigs = mmm.argumentSignatures();
a61af66fc99e Initial load
duke
parents:
diff changeset
214 int count = argSigs.size();
a61af66fc99e Initial load
duke
parents:
diff changeset
215 List res = new ArrayList(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
216
a61af66fc99e Initial load
duke
parents:
diff changeset
217 int slot = mmm.isStatic()? 0 : 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
218 for (int ii = 0; ii < count; ++slot, ++ii) {
a61af66fc99e Initial load
duke
parents:
diff changeset
219 char sigChar = ((String)argSigs.get(ii)).charAt(0);
a61af66fc99e Initial load
duke
parents:
diff changeset
220 BasicType variableType = BasicType.charToBasicType(sigChar);
a61af66fc99e Initial load
duke
parents:
diff changeset
221 res.add(getSlotValue(values, variableType, slot));
a61af66fc99e Initial load
duke
parents:
diff changeset
222 if (sigChar == 'J' || sigChar == 'D') {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 slot++;
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 private ValueImpl getSlotValue(StackValueCollection values,
a61af66fc99e Initial load
duke
parents:
diff changeset
230 BasicType variableType, int ss) {
a61af66fc99e Initial load
duke
parents:
diff changeset
231 ValueImpl valueImpl = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
232 OopHandle handle = null;
a61af66fc99e Initial load
duke
parents:
diff changeset
233 ObjectHeap heap = vm.saObjectHeap();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 if (variableType == BasicType.T_BOOLEAN) {
a61af66fc99e Initial load
duke
parents:
diff changeset
235 valueImpl = (BooleanValueImpl) vm.mirrorOf(values.booleanAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
236 } else if (variableType == BasicType.T_CHAR) {
a61af66fc99e Initial load
duke
parents:
diff changeset
237 valueImpl = (CharValueImpl) vm.mirrorOf(values.charAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
238 } else if (variableType == BasicType.T_FLOAT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
239 valueImpl = (FloatValueImpl) vm.mirrorOf(values.floatAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
240 } else if (variableType == BasicType.T_DOUBLE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 valueImpl = (DoubleValueImpl) vm.mirrorOf(values.doubleAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
242 } else if (variableType == BasicType.T_BYTE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
243 valueImpl = (ByteValueImpl) vm.mirrorOf(values.byteAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
244 } else if (variableType == BasicType.T_SHORT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 valueImpl = (ShortValueImpl) vm.mirrorOf(values.shortAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
246 } else if (variableType == BasicType.T_INT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
247 valueImpl = (IntegerValueImpl) vm.mirrorOf(values.intAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
248 } else if (variableType == BasicType.T_LONG) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 valueImpl = (LongValueImpl) vm.mirrorOf(values.longAt(ss));
a61af66fc99e Initial load
duke
parents:
diff changeset
250 } else if (variableType == BasicType.T_OBJECT) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 // we may have an [Ljava/lang/Object; - i.e., Object[] with the
a61af66fc99e Initial load
duke
parents:
diff changeset
252 // elements themselves may be arrays because every array is an Object.
a61af66fc99e Initial load
duke
parents:
diff changeset
253 handle = values.oopHandleAt(ss);
a61af66fc99e Initial load
duke
parents:
diff changeset
254 valueImpl = (ObjectReferenceImpl) vm.objectMirror(heap.newOop(handle));
a61af66fc99e Initial load
duke
parents:
diff changeset
255 } else if (variableType == BasicType.T_ARRAY) {
a61af66fc99e Initial load
duke
parents:
diff changeset
256 handle = values.oopHandleAt(ss);
a61af66fc99e Initial load
duke
parents:
diff changeset
257 valueImpl = vm.arrayMirror((Array)heap.newOop(handle));
a61af66fc99e Initial load
duke
parents:
diff changeset
258 } else if (variableType == BasicType.T_VOID) {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 valueImpl = new VoidValueImpl(vm);
a61af66fc99e Initial load
duke
parents:
diff changeset
260 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
261 throw new RuntimeException("Should not read here");
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263
a61af66fc99e Initial load
duke
parents:
diff changeset
264 return valueImpl;
a61af66fc99e Initial load
duke
parents:
diff changeset
265 }
a61af66fc99e Initial load
duke
parents:
diff changeset
266
a61af66fc99e Initial load
duke
parents:
diff changeset
267 public void setValue(LocalVariable variableIntf, Value valueIntf)
a61af66fc99e Initial load
duke
parents:
diff changeset
268 throws InvalidTypeException, ClassNotLoadedException {
a61af66fc99e Initial load
duke
parents:
diff changeset
269
a61af66fc99e Initial load
duke
parents:
diff changeset
270 vm.throwNotReadOnlyException("StackFrame.setValue()");
a61af66fc99e Initial load
duke
parents:
diff changeset
271 }
a61af66fc99e Initial load
duke
parents:
diff changeset
272
a61af66fc99e Initial load
duke
parents:
diff changeset
273 public String toString() {
a61af66fc99e Initial load
duke
parents:
diff changeset
274 return location.toString() + " in thread " + thread.toString();
a61af66fc99e Initial load
duke
parents:
diff changeset
275 }
a61af66fc99e Initial load
duke
parents:
diff changeset
276 }