use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJWalker method iterate.
private void iterate(Object object, Method iterator, int maxItems) {
int count = 0;
path.push(getNameFromMethod(iterator));
iterator.setAccessible(true);
try {
Object result = iterator.invoke(object, (Object[]) null);
if (result instanceof Iterator<?>) {
Iterator<?> list = (Iterator<?>) result;
while (list.hasNext() && (count < maxItems)) {
Object data = list.next();
if (data instanceof CorruptData) {
results.add(new InvocationResult(getCurrentPath(), (CorruptData) data));
} else {
Method[] methods = data.getClass().getMethods();
for (Method method : methods) {
if (method.getReturnType().getSimpleName().equals("Iterator")) {
path.push("[" + count + "]/");
iterate(data, method, maxItems);
path.pop();
}
}
}
count++;
}
}
if (result instanceof CorruptData) {
results.add(new InvocationResult(getCurrentPath(), (CorruptData) result));
}
} catch (Exception e) {
System.err.println("Exception thrown by iterator : " + e.getMessage());
logger.log(Level.WARNING, "Exception thrown by iterator", e);
results.add(new InvocationResult(getCurrentPath(), e.getCause()));
// fall through and exit the invocation of this iterator
}
path.pop();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class J9DDRDTFJUtils method handleAsCorruptDataException.
/**
* Convert the supplied error condition into a corrupt data exception
* or re-throw it if it is an instance of Error that we do not want to
* intercept.
*
* @param p the process from the DTFJ context
* @param t error condition to convert
* @return CorruptDataException
*/
public static com.ibm.dtfj.image.CorruptDataException handleAsCorruptDataException(IProcess p, Throwable t) {
if (t instanceof com.ibm.dtfj.image.CorruptDataException) {
// prevent repeated logging of this error by ignoring DTFJ CorruptDataExceptions
return (com.ibm.dtfj.image.CorruptDataException) t;
}
if (isErrorNotToBeIntercepted(t)) {
if (t instanceof Error) {
// re-throw unhandled errors
throw (Error) t;
}
// should not hit this as we handle run time exceptions
throw new RuntimeException(t);
}
if (t instanceof com.ibm.j9ddr.CorruptDataException) {
com.ibm.j9ddr.CorruptDataException cde = (com.ibm.j9ddr.CorruptDataException) t;
logger.log(Level.FINE, "Corrupt data encountered", t);
return newCorruptDataException(p, cde);
}
String message = logError(t);
CorruptData cd = newCorruptData(p, message);
return new DTFJCorruptDataException(cd, t);
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaClass method getInterfaces.
@SuppressWarnings("rawtypes")
public Iterator getInterfaces() {
ArrayList<Object> interfaceNames;
int interfaceCount;
SelfRelativePointer interfaceName;
try {
// a failure in the following calls mean that we cannot find any interfaces
interfaceCount = j9class.romClass().interfaceCount().intValue();
if (interfaceCount > 0xFFFF) {
// class file format limits the number of interfaces to U2 (unsigned 2 bytes)
String msg = String.format("Invalid number of interfaces for class@0x%s", Long.toHexString(j9class.getAddress()));
throw new com.ibm.j9ddr.CorruptDataException(msg);
}
interfaceNames = new ArrayList<Object>(interfaceCount);
interfaceName = j9class.romClass().interfaces();
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
// a failure in the loop should return what we've found so far + a corrupt data
try {
for (int i = 0; i < interfaceCount; i++) {
VoidPointer namePointer = interfaceName.add(i).get();
// a failure to get the name means we can still move to the next iface
try {
interfaceNames.add(J9UTF8Helper.stringValue(J9UTF8Pointer.cast(namePointer)));
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
interfaceNames.add(cd);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
interfaceNames.add(cd);
}
return interfaceNames.iterator();
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaClass method addClassLoaderReference.
private void addClassLoaderReference(List<Object> coll) {
JavaReference jRef = null;
try {
JavaClassLoader classLoader = this.getClassLoader();
if (null != classLoader) {
JavaObject classLoaderObject = classLoader.getObject();
if (null != classLoaderObject) {
jRef = new DTFJJavaReference(this, classLoaderObject, "Classloader", JavaReference.REFERENCE_CLASS_LOADER, JavaReference.HEAP_ROOT_UNKNOWN, JavaReference.REACHABILITY_STRONG);
coll.add(jRef);
}
}
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
coll.add(cd);
}
}
use of com.ibm.dtfj.image.CorruptData in project openj9 by eclipse.
the class DTFJJavaHeap method getSections.
@SuppressWarnings({ "rawtypes", "unchecked" })
public Iterator getSections() {
try {
if (null == sections) {
List sectionList = new ArrayList<ImageSection>();
Iterator<GCHeapRegionDescriptor> it = regions.iterator();
while (it.hasNext()) {
try {
GCHeapRegionDescriptor region = it.next();
long base = region.getLowAddress().getAddress();
long size = region.getHighAddress().getAddress() - base;
String name = String.format("Heap extent at 0x%x (0x%x bytes)", base, size);
sectionList.add(new J9DDRImageSection(MM_HeapRegionDescriptorPointer.getProcess(), base, size, name));
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
sectionList.add(cd);
}
}
sections = sectionList;
}
return sections.iterator();
} catch (Throwable t) {
CorruptData cd = J9DDRDTFJUtils.handleAsCorruptData(DTFJContext.getProcess(), t);
return corruptIterator(cd);
}
}
Aggregations