Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/types/basic/BasicField.java @ 650:54782a4cd321
6812971: SA: re-attaching to process fails
Summary: After attaching, de-attaching SA from a process, the second time attach() call fails. This happens because in VM.initialize(), Universe does not get re-initialized before it is accessed.
Reviewed-by: swamyv
author | poonam |
---|---|
date | Sun, 15 Mar 2009 18:11:46 -0700 |
parents | d1605aabd0a1 |
children | c18cbe5936b8 |
rev | line source |
---|---|
0 | 1 /* |
196 | 2 * Copyright 2000-2008 Sun Microsystems, Inc. All Rights Reserved. |
0 | 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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.types.basic; | |
26 | |
27 import sun.jvm.hotspot.debugger.*; | |
28 import sun.jvm.hotspot.types.*; | |
29 | |
30 /** A basic implementation of Field which should be suitable for | |
31 cross-platform use. */ | |
32 | |
33 public class BasicField implements Field { | |
34 protected BasicTypeDataBase db; | |
35 protected Type type; | |
36 | |
37 private Type containingType; | |
38 private String name; | |
39 private long size; | |
40 private boolean isStatic; | |
41 /** Used for nonstatic fields only */ | |
42 private long offset; | |
43 /** Used for static fields only */ | |
44 private Address staticFieldAddress; | |
45 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
46 // Copy constructor to create NarrowOopField from OopField. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
47 public BasicField(Field fld) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
48 BasicField field = (BasicField)fld; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
49 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
50 this.db = field.db; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
51 this.containingType = field.containingType; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
52 this.name = field.name; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
53 this.type = field.type; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
54 this.size = field.size; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
55 this.isStatic = field.isStatic; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
56 this.offset = field.offset; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
57 this.staticFieldAddress = field.staticFieldAddress; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
58 } |
0 | 59 /** offsetInBytes is ignored if the field is static; |
60 staticFieldAddress is used only if the field is static. */ | |
61 public BasicField(BasicTypeDataBase db, Type containingType, String name, Type type, | |
62 boolean isStatic, long offsetInBytes, Address staticFieldAddress) { | |
63 this.db = db; | |
64 this.containingType = containingType; | |
65 this.name = name; | |
66 this.type = type; | |
67 this.size = type.getSize(); | |
68 this.isStatic = isStatic; | |
69 this.offset = offsetInBytes; | |
70 this.staticFieldAddress = staticFieldAddress; | |
71 } | |
72 | |
73 public String getName() { | |
74 return name; | |
75 } | |
76 | |
77 public Type getType() { | |
78 return type; | |
79 } | |
80 | |
81 public long getSize() { | |
82 return size; | |
83 } | |
84 | |
85 public boolean isStatic() { | |
86 return isStatic; | |
87 } | |
88 | |
89 public long getOffset() throws WrongTypeException { | |
90 if (isStatic) { | |
91 throw new WrongTypeException("field \"" + name + "\" in class " + | |
92 containingType.getName() + " is static"); | |
93 } | |
94 return offset; | |
95 } | |
96 | |
97 public Address getStaticFieldAddress() throws WrongTypeException { | |
98 if (!isStatic) { | |
99 throw new WrongTypeException("field \"" + name + "\" in class " + | |
100 containingType.getName() + " is not static"); | |
101 } | |
102 return staticFieldAddress; | |
103 } | |
104 | |
105 //-------------------------------------------------------------------------------- | |
106 // Dereferencing operations for non-static fields | |
107 // | |
108 | |
109 public boolean getJBoolean (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
110 if (isStatic) { | |
111 throw new WrongTypeException(); | |
112 } | |
113 return addr.getJBooleanAt(offset); | |
114 } | |
115 public byte getJByte (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
116 if (isStatic) { | |
117 throw new WrongTypeException(); | |
118 } | |
119 return addr.getJByteAt(offset); | |
120 } | |
121 public char getJChar (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
122 if (isStatic) { | |
123 throw new WrongTypeException(); | |
124 } | |
125 return addr.getJCharAt(offset); | |
126 } | |
127 public double getJDouble (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
128 if (isStatic) { | |
129 throw new WrongTypeException(); | |
130 } | |
131 return addr.getJDoubleAt(offset); | |
132 } | |
133 public float getJFloat (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
134 if (isStatic) { | |
135 throw new WrongTypeException(); | |
136 } | |
137 return addr.getJFloatAt(offset); | |
138 } | |
139 public int getJInt (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
140 if (isStatic) { | |
141 throw new WrongTypeException(); | |
142 } | |
143 return addr.getJIntAt(offset); | |
144 } | |
145 public long getJLong (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
146 if (isStatic) { | |
147 throw new WrongTypeException(); | |
148 } | |
149 return addr.getJLongAt(offset); | |
150 } | |
151 public short getJShort (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
152 if (isStatic) { | |
153 throw new WrongTypeException(); | |
154 } | |
155 return addr.getJShortAt(offset); | |
156 } | |
157 public long getCInteger (Address addr, CIntegerType type) | |
158 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
159 if (isStatic) { | |
160 throw new WrongTypeException(); | |
161 } | |
162 return addr.getCIntegerAt(offset, type.getSize(), type.isUnsigned()); | |
163 } | |
164 public Address getAddress (Address addr) throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
165 if (isStatic) { | |
166 throw new WrongTypeException(); | |
167 } | |
168 return addr.getAddressAt(offset); | |
169 } | |
170 public OopHandle getOopHandle(Address addr) | |
171 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { | |
172 if (isStatic) { | |
173 throw new WrongTypeException(); | |
174 } | |
175 return addr.getOopHandleAt(offset); | |
176 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
177 public OopHandle getNarrowOopHandle(Address addr) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
178 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
179 if (isStatic) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
180 throw new WrongTypeException(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
181 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
182 return addr.getCompOopHandleAt(offset); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
183 } |
0 | 184 |
185 //-------------------------------------------------------------------------------- | |
186 // Dereferencing operations for static fields | |
187 // | |
188 | |
189 public boolean getJBoolean () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
190 if (!isStatic) { | |
191 throw new WrongTypeException(); | |
192 } | |
193 return staticFieldAddress.getJBooleanAt(0); | |
194 } | |
195 public byte getJByte () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
196 if (!isStatic) { | |
197 throw new WrongTypeException(); | |
198 } | |
199 return staticFieldAddress.getJByteAt(0); | |
200 } | |
201 public char getJChar () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
202 if (!isStatic) { | |
203 throw new WrongTypeException(); | |
204 } | |
205 return staticFieldAddress.getJCharAt(0); | |
206 } | |
207 public double getJDouble () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
208 if (!isStatic) { | |
209 throw new WrongTypeException(); | |
210 } | |
211 return staticFieldAddress.getJDoubleAt(0); | |
212 } | |
213 public float getJFloat () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
214 if (!isStatic) { | |
215 throw new WrongTypeException(); | |
216 } | |
217 return staticFieldAddress.getJFloatAt(0); | |
218 } | |
219 public int getJInt () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
220 if (!isStatic) { | |
221 throw new WrongTypeException(); | |
222 } | |
223 return staticFieldAddress.getJIntAt(0); | |
224 } | |
225 public long getJLong () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
226 if (!isStatic) { | |
227 throw new WrongTypeException(); | |
228 } | |
229 return staticFieldAddress.getJLongAt(0); | |
230 } | |
231 public short getJShort () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
232 if (!isStatic) { | |
233 throw new WrongTypeException(); | |
234 } | |
235 return staticFieldAddress.getJShortAt(0); | |
236 } | |
237 public long getCInteger (CIntegerType type) | |
238 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
239 if (!isStatic) { | |
240 throw new WrongTypeException(); | |
241 } | |
242 return staticFieldAddress.getCIntegerAt(0, type.getSize(), type.isUnsigned()); | |
243 } | |
244 public Address getAddress () throws UnmappedAddressException, UnalignedAddressException, WrongTypeException { | |
245 if (!isStatic) { | |
246 throw new WrongTypeException(); | |
247 } | |
248 return staticFieldAddress.getAddressAt(0); | |
249 } | |
250 public OopHandle getOopHandle() | |
251 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { | |
252 if (!isStatic) { | |
253 throw new WrongTypeException(); | |
254 } | |
255 return staticFieldAddress.getOopHandleAt(0); | |
256 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
257 public OopHandle getNarrowOopHandle() |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
258 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
259 if (!isStatic) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
260 throw new WrongTypeException(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
261 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
262 return staticFieldAddress.getCompOopHandleAt(0); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
263 } |
0 | 264 } |