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