comparison agent/src/share/classes/sun/jvm/hotspot/runtime/VirtualConstructor.java @ 3945:8ed53447f690

Merge
author iveresov
date Thu, 15 Sep 2011 12:44:09 -0700
parents f6f3bb0ee072
children
comparison
equal deleted inserted replaced
3929:f94227b6117b 3945:8ed53447f690
1 /* 1 /*
2 * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 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 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
24 24
25 package sun.jvm.hotspot.runtime; 25 package sun.jvm.hotspot.runtime;
26 26
27 import java.util.*; 27 import java.util.*;
28 import sun.jvm.hotspot.debugger.*; 28 import sun.jvm.hotspot.debugger.*;
29 import sun.jvm.hotspot.debugger.cdbg.*;
30 import sun.jvm.hotspot.types.*; 29 import sun.jvm.hotspot.types.*;
31 30
32 /** This class provides generalized "virtual constructor" 31 /** This class provides generalized "virtual constructor"
33 functionality for VMObjects. In simple terms, it creates 32 functionality for VMObjects. In simple terms, it creates
34 correctly-typed Java wrapper objects for underlying Addresses, 33 correctly-typed Java wrapper objects for underlying Addresses,
37 created for it will be of type 36 created for it will be of type
38 sun.jvm.hotspot.memory.DefNewGeneration, assuming the mapping from 37 sun.jvm.hotspot.memory.DefNewGeneration, assuming the mapping from
39 type "DefNewGeneration" to class 38 type "DefNewGeneration" to class
40 sun.jvm.hotspot.memory.DefNewGeneration has been set up. */ 39 sun.jvm.hotspot.memory.DefNewGeneration has been set up. */
41 40
42 public class VirtualConstructor { 41 public class VirtualConstructor extends InstanceConstructor<VMObject> {
43 private TypeDataBase db; 42 private TypeDataBase db;
44 private Map map; // Map<String, Class> 43 private Map map; // Map<String, Class>
45 44
46 public VirtualConstructor(TypeDataBase db) { 45 public VirtualConstructor(TypeDataBase db) {
47 this.db = db; 46 this.db = db;
76 if (db.addressTypeIsEqualToType(addr, db.lookupType(typeName))) { 75 if (db.addressTypeIsEqualToType(addr, db.lookupType(typeName))) {
77 return (VMObject) VMObjectFactory.newObject((Class) map.get(typeName), addr); 76 return (VMObject) VMObjectFactory.newObject((Class) map.get(typeName), addr);
78 } 77 }
79 } 78 }
80 79
81 String message = "No suitable match for type of address " + addr; 80 throw newWrongTypeException(addr);
82 CDebugger cdbg = VM.getVM().getDebugger().getCDebugger();
83 if (cdbg != null) {
84 // Most common case: V-table pointer is the first field
85 Address vtblPtr = addr.getAddressAt(0);
86 LoadObject lo = cdbg.loadObjectContainingPC(vtblPtr);
87 if (lo != null) {
88 ClosestSymbol symbol = lo.closestSymbolToPC(vtblPtr);
89 if (symbol != null) {
90 message += " (nearest symbol is " + symbol.getName() + ")";
91 }
92 }
93 }
94
95 throw new WrongTypeException(message);
96 } 81 }
97 } 82 }