|
28 | 28 |
|
29 | 29 | import java.util.List;
|
30 | 30 |
|
| 31 | +import jdk.vm.ci.meta.JavaKind; |
| 32 | +import jdk.vm.ci.meta.PrimitiveConstant; |
31 | 33 | import org.graalvm.nativeimage.Platform;
|
32 | 34 | import org.graalvm.nativeimage.Platforms;
|
33 | 35 |
|
@@ -261,7 +263,58 @@ public InterpreterResolvedObjectType resolvedTypeAt(InterpreterResolvedObjectTyp
|
261 | 263 |
|
262 | 264 | public String resolveStringAt(int cpi) {
|
263 | 265 | Object resolvedEntry = resolvedAt(cpi, null);
|
| 266 | + if (resolvedEntry instanceof ReferenceConstant<?> referenceConstant) { |
| 267 | + resolvedEntry = referenceConstant.getReferent(); |
| 268 | + } |
264 | 269 | assert resolvedEntry != null;
|
265 | 270 | return (String) resolvedEntry;
|
266 | 271 | }
|
| 272 | + |
| 273 | + @Override |
| 274 | + public int intAt(int index) { |
| 275 | + checkTag(index, CONSTANT_Integer); |
| 276 | + Object entry = cachedEntries[index]; |
| 277 | + assert entry == null || entry instanceof PrimitiveConstant; |
| 278 | + if (entry instanceof PrimitiveConstant primitiveConstant) { |
| 279 | + assert primitiveConstant.getJavaKind() == JavaKind.Int; |
| 280 | + return primitiveConstant.asInt(); |
| 281 | + } |
| 282 | + return super.intAt(index); |
| 283 | + } |
| 284 | + |
| 285 | + @Override |
| 286 | + public float floatAt(int index) { |
| 287 | + checkTag(index, CONSTANT_Float); |
| 288 | + Object entry = cachedEntries[index]; |
| 289 | + assert entry == null || entry instanceof PrimitiveConstant; |
| 290 | + if (entry instanceof PrimitiveConstant primitiveConstant) { |
| 291 | + assert primitiveConstant.getJavaKind() == JavaKind.Float; |
| 292 | + return primitiveConstant.asFloat(); |
| 293 | + } |
| 294 | + return super.floatAt(index); |
| 295 | + } |
| 296 | + |
| 297 | + @Override |
| 298 | + public double doubleAt(int index) { |
| 299 | + checkTag(index, CONSTANT_Double); |
| 300 | + Object entry = cachedEntries[index]; |
| 301 | + assert entry == null || entry instanceof PrimitiveConstant; |
| 302 | + if (entry instanceof PrimitiveConstant primitiveConstant) { |
| 303 | + assert primitiveConstant.getJavaKind() == JavaKind.Double; |
| 304 | + return primitiveConstant.asDouble(); |
| 305 | + } |
| 306 | + return super.doubleAt(index); |
| 307 | + } |
| 308 | + |
| 309 | + @Override |
| 310 | + public long longAt(int index) { |
| 311 | + checkTag(index, CONSTANT_Long); |
| 312 | + Object entry = cachedEntries[index]; |
| 313 | + assert entry == null || entry instanceof PrimitiveConstant; |
| 314 | + if (entry instanceof PrimitiveConstant primitiveConstant) { |
| 315 | + assert primitiveConstant.getJavaKind() == JavaKind.Long; |
| 316 | + return primitiveConstant.asLong(); |
| 317 | + } |
| 318 | + return super.longAt(index); |
| 319 | + } |
267 | 320 | }
|
0 commit comments