41 /** Used for nonstatic fields only */ |
41 /** Used for nonstatic fields only */ |
42 private long offset; |
42 private long offset; |
43 /** Used for static fields only */ |
43 /** Used for static fields only */ |
44 private Address staticFieldAddress; |
44 private Address staticFieldAddress; |
45 |
45 |
|
46 // Copy constructor to create NarrowOopField from OopField. |
|
47 public BasicField(Field fld) { |
|
48 BasicField field = (BasicField)fld; |
|
49 |
|
50 this.db = field.db; |
|
51 this.containingType = field.containingType; |
|
52 this.name = field.name; |
|
53 this.type = field.type; |
|
54 this.size = field.size; |
|
55 this.isStatic = field.isStatic; |
|
56 this.offset = field.offset; |
|
57 this.staticFieldAddress = field.staticFieldAddress; |
|
58 } |
46 /** offsetInBytes is ignored if the field is static; |
59 /** offsetInBytes is ignored if the field is static; |
47 staticFieldAddress is used only if the field is static. */ |
60 staticFieldAddress is used only if the field is static. */ |
48 public BasicField(BasicTypeDataBase db, Type containingType, String name, Type type, |
61 public BasicField(BasicTypeDataBase db, Type containingType, String name, Type type, |
49 boolean isStatic, long offsetInBytes, Address staticFieldAddress) { |
62 boolean isStatic, long offsetInBytes, Address staticFieldAddress) { |
50 this.db = db; |
63 this.db = db; |
159 if (isStatic) { |
172 if (isStatic) { |
160 throw new WrongTypeException(); |
173 throw new WrongTypeException(); |
161 } |
174 } |
162 return addr.getOopHandleAt(offset); |
175 return addr.getOopHandleAt(offset); |
163 } |
176 } |
|
177 public OopHandle getNarrowOopHandle(Address addr) |
|
178 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { |
|
179 if (isStatic) { |
|
180 throw new WrongTypeException(); |
|
181 } |
|
182 return addr.getCompOopHandleAt(offset); |
|
183 } |
164 |
184 |
165 //-------------------------------------------------------------------------------- |
185 //-------------------------------------------------------------------------------- |
166 // Dereferencing operations for static fields |
186 // Dereferencing operations for static fields |
167 // |
187 // |
168 |
188 |
232 if (!isStatic) { |
252 if (!isStatic) { |
233 throw new WrongTypeException(); |
253 throw new WrongTypeException(); |
234 } |
254 } |
235 return staticFieldAddress.getOopHandleAt(0); |
255 return staticFieldAddress.getOopHandleAt(0); |
236 } |
256 } |
|
257 public OopHandle getNarrowOopHandle() |
|
258 throws UnmappedAddressException, UnalignedAddressException, WrongTypeException, NotInHeapException { |
|
259 if (!isStatic) { |
|
260 throw new WrongTypeException(); |
|
261 } |
|
262 return staticFieldAddress.getCompOopHandleAt(0); |
|
263 } |
237 } |
264 } |