use of com.ibm.dtfj.image.ImageThread in project openj9 by eclipse.
the class JavaThreadTest method getImageThreadTest.
@Test
public // JEXTRACT: only EVER throws DataUnavailableException with TCK core. We do better.
void getImageThreadTest() {
for (int i = 0; i < jextractTestObjects.size(); i++) {
JavaThread t1 = (JavaThread) jextractTestObjects.get(i);
ImageThread i1;
try {
i1 = (ImageThread) t1.getImageThread();
// System.out.println(i1.getID());
} catch (CorruptDataException e) {
System.out.println("CDE on thread: " + i);
} catch (DataUnavailable e) {
System.out.println("DUA on thread: " + i);
}
}
imageThreadComparator.testComparatorEquals(ddrTestObjects, jextractTestObjects, "getImageThread");
}
use of com.ibm.dtfj.image.ImageThread in project openj9 by eclipse.
the class JCImageProcess method getCurrentThread.
/**
*/
public ImageThread getCurrentThread() throws CorruptDataException {
ImageThread currentThread = null;
if (fCurrentThreadID != IBuilderData.NOT_AVAILABLE) {
// Return the indicated thread
ImagePointer ip = fImageAddressSpace.getPointer(fCurrentThreadID);
currentThread = getImageThread(ip);
if (currentThread == null) {
throw new CorruptDataException(new JCCorruptData("Bad native thread ID", ip));
}
}
return currentThread;
}
use of com.ibm.dtfj.image.ImageThread in project openj9 by eclipse.
the class InfoThreadCommand method getJavaThreads.
private Map getJavaThreads(String id) {
Map threads = new HashMap();
ManagedRuntime mr = ctx.getRuntime();
if (mr instanceof JavaRuntime) {
JavaRuntime jr = (JavaRuntime) mr;
Iterator itThread = jr.getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
// skip any corrupt threads
if (next instanceof CorruptData)
continue;
JavaThread jt = (JavaThread) next;
// Obtain the native thread ID for this thread, and for zOS also obtain the TCB
String currentTID = null;
String currentTCB = null;
try {
ImageThread it = jt.getImageThread();
currentTID = it.getID();
if (_is_zOS) {
currentTCB = it.getProperties().getProperty("TCB");
}
} catch (DTFJException e) {
// Continue with what we have obtained so far
}
if (null == id) {
// save all orphaned java threads in a list within the hashmap
if (null == currentTID) {
if (threads.containsKey(null)) {
ArrayList ta = (ArrayList) threads.get(null);
ta.add(new ThreadData(jt, jr));
} else {
ArrayList ta = new ArrayList(1);
ta.add(new ThreadData(jt, jr));
threads.put(null, ta);
}
} else {
threads.put(currentTID, new ThreadData(jt, jr));
}
} else if (id.equalsIgnoreCase(currentTID) || id.equalsIgnoreCase(currentTCB)) {
// We just want the specific Java thread that matches the native thread ID or zOS TCB
threads.put(currentTID, new ThreadData(jt, jr));
}
}
}
return threads;
}
use of com.ibm.dtfj.image.ImageThread in project openj9 by eclipse.
the class InfoThreadCommand method printThreadSummary.
private void printThreadSummary(ImageProcess ip) {
// Prints a summary list of native thread IDs
int count = 0;
Iterator itThread = ip.getThreads();
while (itThread.hasNext()) {
Object next = itThread.next();
if (next instanceof CorruptData)
continue;
ImageThread it = (ImageThread) next;
if (count % 8 == 0) {
if (0 == count)
out.print("\n\nNative thread IDs for current process:");
out.print("\n ");
}
try {
out.print(Utils.padWithSpaces(it.getID(), 8));
} catch (CorruptDataException e) {
out.print(Exceptions.getCorruptDataExceptionString());
}
count++;
}
out.print("\n");
}
use of com.ibm.dtfj.image.ImageThread in project openj9 by eclipse.
the class DTFJJavaThread method equals.
public boolean equals(Object object) {
// note that we can't get image threads on all platforms and in all situations but we still need to return equals correctly
ImageThread imageThread = null;
try {
imageThread = getImageThread();
} catch (DataUnavailable e) {
// Do nothing
} catch (CorruptDataException e) {
// Do nothing
}
boolean isEqual = (null == imageThread) ? (this == object) : false;
// By definition objects from different images can not be equal
if ((null != imageThread) && (object instanceof DTFJJavaThread)) {
DTFJJavaThread local = (DTFJJavaThread) object;
try {
isEqual = imageThread.getID().equals(local.getImageThread().getID());
} catch (CorruptDataException e) {
// Do nothing
} catch (DataUnavailable e) {
// Do nothing
}
}
return isEqual;
}
Aggregations