Bug 8776

Summary: 1.0 Snippet editor does not work with new J9 JCLs
Product: [Eclipse Project] JDT Reporter: Darin Wright <darin.eclipse>
Component: DebugAssignee: Darin Wright <darin.eclipse>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: tim_koss
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: Windows 2000   
Whiteboard:

Description Darin Wright CLA 2002-01-30 13:07:26 EST
The 1.0 Snippet editor does not work with the latest J9 JCLs. The reason for 
this is that the implementation of "Method.invoke(...)" has changed from being 
native, to being source. As the snippet editor attempts to position itself to 
the correct location to perform an evaluation, an assumption it makes about the 
number of frames on the stack is now invalid.
Comment 1 Darin Wright CLA 2002-01-30 13:51:09 EST
Source for patch in JavaSnippetEditor#handleDebugEvent

	public void handleDebugEvent(DebugEvent e) {
		Object source = e.getSource();
		if (source instanceof IDebugElement) {
			IDebugElement de = (IDebugElement)source;
			if (de.getElementType() == IDebugElement.DEBUG_TARGET) {
				if (de.getDebugTarget().equals(fVM)) {
					if (e.getKind() == 
DebugEvent.TERMINATE) {
						Runnable r = new Runnable() {
							public void run() {
								vmTerminated();
							}
						};
						getShell().getDisplay
().asyncExec(r);
					}
				}
			} else if (de instanceof IJavaThread) {
				if (e.getKind() == DebugEvent.SUSPEND) {
					IJavaThread jt = (IJavaThread)de;
					try {
						IJavaStackFrame f= 
(IJavaStackFrame)jt.getTopStackFrame();
						if (f != null) {
							if (e.getDetail() == 
DebugEvent.STEP_END && f.getLineNumber() == 9 && f.getDeclaringTypeName().equals
("org.eclipse.jdt.internal.ui.snippeteditor.ScrapbookMain1")) { //$NON-NLS-1$
								fThread = jt;
							} else if (e.getDetail
() == DebugEvent.BREAKPOINT && jt.getBreakpoint().equals
(ScrapbookLauncher.getDefault().getMagicBreakpoint(jt.getDebugTarget()))) {
								// locate 
the 'eval' method and step over
								IDebugElement[] 
frames = jt.getChildren();
								for (int i = 0; 
i < frames.length; i++) {
								
	IJavaStackFrame frame = (IJavaStackFrame)frames[i];
									if 
(frame.getReceivingTypeName().equals
("org.eclipse.jdt.internal.ui.snippeteditor.ScrapbookMain1") && frame.getName
().equals("eval")) { //$NON-NLS-1$ //$NON-NLS-2$
									
	frame.stepOver();
									
	break;
									}
								}
							}
						}
					} catch (DebugException ex) {
						JavaPlugin.log(ex);
					}
				}
			}
		}
	}
Comment 2 Kai-Uwe Maetzel CLA 2002-02-08 09:29:51 EST
Included changed with rollup2, version 1.0.
Comment 3 Andre Weinand CLA 2002-02-13 06:26:03 EST
Verified for J9: ive11022001.zip