本文整理汇总了Java中sun.jvm.hotspot.debugger.Address.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Address.equals方法的具体用法?Java Address.equals怎么用?Java Address.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.jvm.hotspot.debugger.Address
的用法示例。
在下文中一共展示了Address.equals方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findDynamicTypeForAddress
import sun.jvm.hotspot.debugger.Address; //导入方法依赖的package包/类
public Type findDynamicTypeForAddress(Address addr, Type baseType) {
// This implementation should be suitably platform-independent; we
// search nearby memory for the vtbl value of the given type.
if (vtblForType(baseType) == null) {
// Type was not polymorphic which is an error of some sort
throw new InternalError(baseType + " does not appear to be polymorphic");
}
// This is a more restricted version of guessTypeForAddress since
// that function has some limitations since it doesn't really know
// where in the hierarchy a virtual type starts and just poking
// around in memory is likely to trip over some vtable address,
// resulting in false positives. Eventually all uses should
// switch to this logic but in the interests of stability it will
// be separate for the moment.
// Assuming that the base type is truly the first polymorphic type
// then the vtbl for all subclasss should be at several defined
// locations so only those locations will be checked. It's also
// required that the caller knows that the static type is at least
// baseType. See the notes in guessTypeForAddress for the logic of
// the locations searched.
Address loc1 = addr.getAddressAt(0);
Address loc2 = null;
Address loc3 = null;
long offset2 = baseType.getSize();
// I don't think this should be misaligned under any
// circumstances, but I'm not sure (FIXME: also not sure which
// way to go here, up or down -- assuming down)
offset2 = offset2 - (offset2 % getAddressSize()) - getAddressSize();
if (offset2 > 0) {
loc2 = addr.getAddressAt(offset2);
}
long offset3 = offset2 - getAddressSize();
if (offset3 > 0) {
loc3 = addr.getAddressAt(offset3);
}
Type loc2Match = null;
Type loc3Match = null;
for (Iterator iter = getTypes(); iter.hasNext(); ) {
Type type = (Type) iter.next();
Type superClass = type;
while (superClass != baseType && superClass != null) {
superClass = superClass.getSuperclass();
}
if (superClass == null) continue;
Address vtblAddr = vtblForType(type);
if (vtblAddr == null) {
// This occurs sometimes for intermediate types that are never
// instantiated.
if (DEBUG) {
System.err.println("null vtbl for " + type);
}
continue;
}
// Prefer loc1 match
if (vtblAddr.equals(loc1)) return type;
if (loc2 != null && loc2Match == null && vtblAddr.equals(loc2)) {
loc2Match = type;
}
if (loc3 != null && loc3Match == null && vtblAddr.equals(loc3)) {
loc3Match = type;
}
}
if (loc2Match != null) return loc2Match;
if (loc3Match != null) return loc3Match;
return null;
}