Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 317643
Collapse All | Expand All

(-)model/org/eclipse/jdt/internal/debug/core/model/JDILocalVariable.java (+6 lines)
Lines 13-18 Link Here
13
13
14
import org.eclipse.debug.core.DebugEvent;
14
import org.eclipse.debug.core.DebugEvent;
15
import org.eclipse.debug.core.DebugException;
15
import org.eclipse.debug.core.DebugException;
16
import org.eclipse.debug.core.model.IVariable;
17
import org.eclipse.jdt.debug.core.IJavaVariable;
18
import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame.AnnonLocalVariable;
16
19
17
import com.ibm.icu.text.MessageFormat;
20
import com.ibm.icu.text.MessageFormat;
18
import com.sun.jdi.ClassNotLoadedException;
21
import com.sun.jdi.ClassNotLoadedException;
Lines 54-59 Link Here
54
	protected Value retrieveValue() throws DebugException {
57
	protected Value retrieveValue() throws DebugException {
55
		synchronized (fStackFrame.getThread()) {
58
		synchronized (fStackFrame.getThread()) {
56
			if (getStackFrame().isSuspended()) {
59
			if (getStackFrame().isSuspended()) {
60
				if (fLocal instanceof AnnonLocalVariable) {
61
					return ((AnnonLocalVariable) fLocal).actuallyGetValue();
62
				}
57
				return getStackFrame().getUnderlyingStackFrame().getValue(fLocal);
63
				return getStackFrame().getUnderlyingStackFrame().getValue(fLocal);
58
			}
64
			}
59
		}
65
		}
(-)model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java (-1 / +61 lines)
Lines 10-30 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.debug.core.model;
11
package org.eclipse.jdt.internal.debug.core.model;
12
12
13
 
13
14
import java.util.ArrayList;
14
import java.util.ArrayList;
15
import java.util.Collections;
15
import java.util.Collections;
16
import java.util.Comparator;
16
import java.util.Comparator;
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import java.util.List;
19
19
20
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.IStatus;
21
import org.eclipse.core.runtime.Status;
22
import org.eclipse.core.runtime.Status;
22
import org.eclipse.debug.core.DebugEvent;
23
import org.eclipse.debug.core.DebugEvent;
23
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.DebugException;
24
import org.eclipse.debug.core.model.IRegisterGroup;
25
import org.eclipse.debug.core.model.IRegisterGroup;
25
import org.eclipse.debug.core.model.IStackFrame;
26
import org.eclipse.debug.core.model.IStackFrame;
27
import org.eclipse.debug.core.model.IStep;
28
import org.eclipse.debug.core.model.ISuspendResume;
29
import org.eclipse.debug.core.model.ITerminate;
26
import org.eclipse.debug.core.model.IThread;
30
import org.eclipse.debug.core.model.IThread;
27
import org.eclipse.debug.core.model.IVariable;
31
import org.eclipse.debug.core.model.IVariable;
32
import org.eclipse.jdi.internal.AccessibleImpl;
33
import org.eclipse.jdi.internal.FieldImpl;
34
import org.eclipse.jdi.internal.LocalVariableImpl;
35
import org.eclipse.jdi.internal.MethodImpl;
28
import org.eclipse.jdi.internal.ValueImpl;
36
import org.eclipse.jdi.internal.ValueImpl;
29
import org.eclipse.jdi.internal.VirtualMachineImpl;
37
import org.eclipse.jdi.internal.VirtualMachineImpl;
30
import org.eclipse.jdt.core.Signature;
38
import org.eclipse.jdt.core.Signature;
Lines 53-58 Link Here
53
import com.sun.jdi.ReferenceType;
61
import com.sun.jdi.ReferenceType;
54
import com.sun.jdi.StackFrame;
62
import com.sun.jdi.StackFrame;
55
import com.sun.jdi.Type;
63
import com.sun.jdi.Type;
64
import com.sun.jdi.Value;
56
import com.sun.jdi.VirtualMachine;
65
import com.sun.jdi.VirtualMachine;
57
66
58
/**
67
/**
Lines 61-66 Link Here
61
70
62
public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame {
71
public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame {
63
72
73
	private static final String PARENT_SCOPED_PREFIX = "val$"; //$NON-NLS-1$
74
75
	final class AnnonLocalVariable extends LocalVariableImpl {
76
		private final FieldImpl f;
77
78
		private AnnonLocalVariable(VirtualMachineImpl vmImpl, MethodImpl method, long codeIndex, String name,
79
				String signature, String genericSignature, int length, int slot, boolean isArgument, FieldImpl f) {
80
			super(vmImpl, method, codeIndex, name, signature, genericSignature, length, slot, isArgument);
81
			this.f = f;
82
		}
83
84
		public boolean isThis() {
85
			return false;
86
		}
87
88
		public boolean isArgument() {
89
			return false;
90
		}
91
92
		Value actuallyGetValue() throws DebugException {
93
			return getUnderlyingThisObject().getValue(f);
94
		}
95
	}
96
64
	/**
97
	/**
65
	 * This frame's depth in the call stack (0 == bottom of stack).
98
	 * This frame's depth in the call stack (0 == bottom of stack).
66
	 * A new frame is indicated by -2.
99
	 * A new frame is indicated by -2.
Lines 683-692 Link Here
683
			} catch (RuntimeException e) {
716
			} catch (RuntimeException e) {
684
				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2,new String[] {e.toString()}), e); 
717
				targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2,new String[] {e.toString()}), e); 
685
			}
718
			}
719
720
			List fields= getUnderlyingMethod().declaringType().fields();
721
			for (int i = 0; i < fields.size(); ++i) {
722
				Object next= fields.get(i);
723
				if (next instanceof FieldImpl) {
724
					FieldImpl f= (FieldImpl) next;
725
726
					if (isParentScopedVariable(f)) {
727
						variables.add(new AnnonLocalVariable(f.virtualMachineImpl(), (MethodImpl) getUnderlyingMethod(),
728
								0, washHiddenFieldName(f), f.signature(), f.genericSignature(), 0,
729
								-1, false, f));
730
					}
731
				}
732
			}
686
			return variables;
733
			return variables;
687
		}
734
		}
688
	}
735
	}
689
736
737
738
	private boolean isParentScopedVariable(final FieldImpl f) {
739
		final int mod= f.modifiers();
740
		return (mod & AccessibleImpl.MODIFIER_ACC_SYNTHETIC) != 0 &&
741
			(mod & AccessibleImpl.MODIFIER_ACC_FINAL) != 0 &&
742
			(mod & AccessibleImpl.MODIFIER_ACC_PRIVATE) != 0 &&
743
			f.name().startsWith(PARENT_SCOPED_PREFIX);
744
	}
745
746
	private static String washHiddenFieldName(final FieldImpl f) {
747
		return f.name().substring(PARENT_SCOPED_PREFIX.length());
748
	}
749
690
	/**
750
	/**
691
	 * Retrieves 'this' from the underlying stack frame.
751
	 * Retrieves 'this' from the underlying stack frame.
692
	 * Returns <code>null</code> for static stack frames.
752
	 * Returns <code>null</code> for static stack frames.
(-)ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java (-1 / +6 lines)
Lines 383-389 Link Here
383
            					}
383
            					}
384
            				} else {
384
            				} else {
385
            					// compare unresolved signatures
385
            					// compare unresolved signatures
386
            					if (((frame.isConstructor() && method.isConstructor()) || frame.getMethodName().equals(method.getElementName()))
386
            					// in an anonymous inner class, method is set to the class' parent here,
387
            					// so we can just check if it has any children to work out if we might
388
            					// be in an inner class, which makes it worth doing the deeper look.
389
            					// Alternatively, always do it (i.e. equal = true)?
390
            					if (method.getChildren().length != 0 ||
391
            							((frame.isConstructor() && method.isConstructor()) || frame.getMethodName().equals(method.getElementName()))
387
            							&& frame.getDeclaringTypeName().endsWith(method.getDeclaringType().getElementName())
392
            							&& frame.getDeclaringTypeName().endsWith(method.getDeclaringType().getElementName())
388
            							&& frame.getArgumentTypeNames().size() == method.getNumberOfParameters()) {
393
            							&& frame.getArgumentTypeNames().size() == method.getNumberOfParameters()) {
389
            						equal = true;
394
            						equal = true;

Return to bug 317643