use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class J9JavaStackIterator method next.
public J9JavaStackPointer next() {
try {
if (hasNext()) {
J9JavaStackPointer next;
next = currentStack;
currentStack = currentStack.previous();
return next;
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
} catch (CorruptDataException cde) {
// broken link to previous stack section, terminate the walk
currentStack = J9JavaStackPointer.NULL;
raiseCorruptDataEvent("Error getting next stack section", cde, false);
return null;
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class GCVMThreadStackSlotIterator method scanSlots.
static void scanSlots(J9VMThreadPointer walkThread, IStackWalkerCallbacks stackWalkerCallbacks, boolean includeStackFrameClassReferences, boolean trackVisibleFrameDepth) {
WalkState walkState = new WalkState();
walkState.flags = J9_STACKWALK_ITERATE_O_SLOTS | J9_STACKWALK_DO_NOT_SNIFF_AND_WHACK;
walkState.walkThread = walkThread;
walkState.callBacks = stackWalkerCallbacks;
if (trackVisibleFrameDepth) {
walkState.skipCount = 0;
walkState.flags |= J9_STACKWALK_VISIBLE_ONLY;
} else {
walkState.flags |= J9_STACKWALK_SKIP_INLINES;
}
if (includeStackFrameClassReferences) {
walkState.flags |= J9_STACKWALK_ITERATE_METHOD_CLASS_SLOTS;
}
StackWalkResult result = StackWalkResult.STACK_CORRUPT;
result = StackWalker.walkStackFrames(walkState);
if (StackWalkResult.NONE != result) {
/* Explicitly raising a corrupt data event here since returning StackWalkResult.STACK_CORRUPT is fairly common if a core is not taken at a safe gc point */
CorruptDataException corruptDataException = new CorruptDataException("Stack walk returned: " + result + " for vmThread: " + walkThread.getHexAddress());
EventManager.raiseCorruptDataEvent("", corruptDataException, false);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class MonitorTable method initializedCachedMonitorTable.
private void initializedCachedMonitorTable() {
cachedMonitorTable = new HashMap<J9ObjectPointer, J9ObjectMonitorPointer>();
try {
Iterator<J9ObjectMonitorPointer> iterator = iterator();
while (iterator.hasNext()) {
J9ObjectMonitorPointer objectMonitor = iterator.next();
J9ObjectPointer object = J9ObjectPointer.cast(objectMonitor.monitor().userData());
cachedMonitorTable.put(object, objectMonitor);
}
} catch (CorruptDataException e) {
raiseCorruptDataEvent("Error building cached monitor table", e, false);
}
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class VMConstantPool method getFieldOffset.
/**
* Get a field offset from the constant pool.
* @param index A J9VmconstantpoolConstants index into the constant pool. Must be for a static or instance field reference.
* @return Either the offset to the object, or null if the field's class is not resolved in the constant pool.
* @throws CorruptDataException If the field cannot be found in the related class or the CP index is not a field reference.
*/
public static J9ObjectFieldOffset getFieldOffset(long index) throws CorruptDataException {
if (_constantPool.length <= index || 0 > index) {
throw new IndexOutOfBoundsException("Index outside of constant pool bounds");
}
int cpIndex = (int) index;
long shapeDesc = ConstantPoolHelpers.J9_CP_TYPE(_cpShapeDescription, cpIndex);
if (J9CPTYPE_FIELD != shapeDesc) {
throw new CorruptDataException("VMConstantPool[" + index + "] CP_TYPE is not J9CPTYPE_FIELD");
}
/* The offset of the field, to be returned */
J9ObjectFieldOffset offset = null;
if (null != _constantPool[cpIndex]) {
offset = (J9ObjectFieldOffset) _constantPool[cpIndex];
} else {
J9ROMFieldRefPointer romRef = J9ROMFieldRefPointer.cast(_romCPStart.add(cpIndex));
J9ClassPointer refClass = getClass(romRef.classRefCPIndex().longValue());
J9ClassPointer currentClass = refClass;
if (currentClass.notNull()) {
/* If the current class is J9ClassPointer.NULL, return null as the field offset */
/* Resolve the fieldname, starting from the current class,
* and working up the class hierarchy towards the super classes. This should
* properly handle shadowed fields.
*/
String fieldName = J9UTF8Helper.stringValue(romRef.nameAndSignature().name());
String signature = J9UTF8Helper.stringValue(romRef.nameAndSignature().signature());
while (currentClass.notNull() && (null == offset)) {
Iterator<J9ObjectFieldOffset> fields = J9ClassHelper.getFieldOffsets(currentClass);
while (fields.hasNext()) {
J9ObjectFieldOffset field = fields.next();
if (field.getName().equals(fieldName) && field.getSignature().equals(signature)) {
offset = field;
break;
}
}
currentClass = J9ClassHelper.superclass(currentClass);
}
if (null == offset) {
/* The field should exist in the class it points to, unless the constant pool is corrupt or wrong */
throw new CorruptDataException("VMConstantPool[" + index + "] field not found: " + J9ClassHelper.getName(refClass) + "." + fieldName + " " + signature);
} else {
_constantPool[cpIndex] = offset;
}
}
}
return offset;
}
use of com.ibm.j9ddr.CorruptDataException in project openj9 by eclipse.
the class StringTable method iterator.
public SlotIterator<J9ObjectPointer> iterator() {
return new SlotIterator<J9ObjectPointer>() {
private SlotIterator<PointerPointer> hashTableIterator = null;
private long currentIndex = 0;
public boolean hasNext() {
while (true) {
// Is the current iterator good?
if (hashTableIterator != null) {
// Are there still entries?
if (hashTableIterator.hasNext()) {
return true;
}
// Move to the next hash table
currentIndex++;
}
// Are there more hash tables?
if (currentIndex >= _tableCount) {
hashTableIterator = null;
return false;
}
// Get the next hash table iterator
try {
J9HashTablePointer hashTable = J9HashTablePointer.cast(_stringTable._table().at(currentIndex));
HashTable<PointerPointer> currentHashTable = HashTable.fromJ9HashTable(hashTable, false, PointerPointer.class, _hashFn, new StringComparatorFunction<PointerPointer>());
hashTableIterator = currentHashTable.iterator();
} catch (CorruptDataException e) {
raiseCorruptDataEvent("Error getting next item", e, false);
// Keep trying
}
}
}
public J9ObjectPointer next() {
if (hasNext()) {
PointerPointer next = hashTableIterator.next();
return J9ObjectPointer.cast(next);
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
}
public VoidPointer nextAddress() {
if (hasNext()) {
return VoidPointer.cast(hashTableIterator.nextAddress());
} else {
throw new NoSuchElementException("There are no more items available through this iterator");
}
}
public void remove() {
throw new UnsupportedOperationException("The image is read only and cannot be modified.");
}
};
}
Aggregations