1 11 package org.eclipse.jdt.internal.debug.ui.monitors; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.debug.core.DebugException; 15 import org.eclipse.debug.core.model.IDebugElement; 16 import org.eclipse.debug.core.model.IStackFrame; 17 import org.eclipse.debug.internal.ui.viewers.provisional.IPresentationContext; 18 import org.eclipse.jdt.debug.core.IJavaDebugTarget; 19 import org.eclipse.jdt.debug.core.IJavaThread; 20 import org.eclipse.jdt.debug.ui.JavaDebugUtils; 21 22 25 public class AsyncJavaThreadAdapter extends AsyncMonitorAdapter { 26 27 protected Object [] getChildren(Object parent, IPresentationContext context) throws CoreException { 28 IJavaThread thread = (IJavaThread) parent; 29 if (!thread.isSuspended()) { 30 return EMPTY; 31 } 32 try { 33 IStackFrame[] frames = thread.getStackFrames(); 34 if (!isDisplayMonitors()) { 35 return frames; 36 } 37 38 Object [] children; 39 int length = frames.length; 40 if (((IJavaDebugTarget) thread.getDebugTarget()).supportsMonitorInformation()) { 41 IDebugElement[] ownedMonitors = JavaDebugUtils.getOwnedMonitors(thread); 42 IDebugElement contendedMonitor = JavaDebugUtils.getContendedMonitor(thread); 43 44 if (ownedMonitors != null) { 45 length += ownedMonitors.length; 46 } 47 if (contendedMonitor != null) { 48 length++; 49 } 50 children = new Object [length]; 51 if (ownedMonitors != null && ownedMonitors.length > 0) { 52 System.arraycopy(ownedMonitors, 0, children, 0, ownedMonitors.length); 53 } 54 if (contendedMonitor != null) { 55 children[ownedMonitors.length] = contendedMonitor; 57 } 58 } else { 59 children = new Object [length + 1]; 60 children[0] = new NoMonitorInformationElement(thread.getDebugTarget()); 61 } 62 int offset = children.length - frames.length; 63 System.arraycopy(frames, 0, children, offset, frames.length); 64 return children; 65 } catch (DebugException e) { 66 return EMPTY; 67 } 68 } 69 70 protected boolean hasChildren(Object element, IPresentationContext context) throws CoreException { 71 IJavaThread thread = (IJavaThread) element; 72 return thread.hasStackFrames(); 73 } 74 75 } 76 | Popular Tags |