Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 172466 Details for
Bug 317643
Variables from parent scope aren't available during evaluations in inner classes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proof of concept fix inside JDIStackFrame/JDILocalVariable
annoninnervariables1.diff (text/plain), 7.00 KB, created by
Chris West (Faux)
on 2010-06-22 17:43:32 EDT
(
hide
)
Description:
Proof of concept fix inside JDIStackFrame/JDILocalVariable
Filename:
MIME Type:
Creator:
Chris West (Faux)
Created:
2010-06-22 17:43:32 EDT
Size:
7.00 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.debug >Index: model/org/eclipse/jdt/internal/debug/core/model/JDILocalVariable.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDILocalVariable.java,v >retrieving revision 1.26 >diff -u -r1.26 JDILocalVariable.java >--- model/org/eclipse/jdt/internal/debug/core/model/JDILocalVariable.java 29 May 2008 15:48:20 -0000 1.26 >+++ model/org/eclipse/jdt/internal/debug/core/model/JDILocalVariable.java 22 Jun 2010 21:32:58 -0000 >@@ -13,6 +13,9 @@ > > import org.eclipse.debug.core.DebugEvent; > import org.eclipse.debug.core.DebugException; >+import org.eclipse.debug.core.model.IVariable; >+import org.eclipse.jdt.debug.core.IJavaVariable; >+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame.AnnonLocalVariable; > > import com.ibm.icu.text.MessageFormat; > import com.sun.jdi.ClassNotLoadedException; >@@ -54,6 +57,9 @@ > protected Value retrieveValue() throws DebugException { > synchronized (fStackFrame.getThread()) { > if (getStackFrame().isSuspended()) { >+ if (fLocal instanceof AnnonLocalVariable) { >+ return ((AnnonLocalVariable) fLocal).actuallyGetValue(); >+ } > return getStackFrame().getUnderlyingStackFrame().getValue(fLocal); > } > } >Index: model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java,v >retrieving revision 1.98 >diff -u -r1.98 JDIStackFrame.java >--- model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java 29 May 2008 15:48:20 -0000 1.98 >+++ model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java 22 Jun 2010 21:32:59 -0000 >@@ -10,21 +10,29 @@ > *******************************************************************************/ > package org.eclipse.jdt.internal.debug.core.model; > >- >+ > import java.util.ArrayList; > import java.util.Collections; > import java.util.Comparator; > import java.util.Iterator; > import java.util.List; > >+import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IStatus; > import org.eclipse.core.runtime.Status; > import org.eclipse.debug.core.DebugEvent; > import org.eclipse.debug.core.DebugException; > import org.eclipse.debug.core.model.IRegisterGroup; > import org.eclipse.debug.core.model.IStackFrame; >+import org.eclipse.debug.core.model.IStep; >+import org.eclipse.debug.core.model.ISuspendResume; >+import org.eclipse.debug.core.model.ITerminate; > import org.eclipse.debug.core.model.IThread; > import org.eclipse.debug.core.model.IVariable; >+import org.eclipse.jdi.internal.AccessibleImpl; >+import org.eclipse.jdi.internal.FieldImpl; >+import org.eclipse.jdi.internal.LocalVariableImpl; >+import org.eclipse.jdi.internal.MethodImpl; > import org.eclipse.jdi.internal.ValueImpl; > import org.eclipse.jdi.internal.VirtualMachineImpl; > import org.eclipse.jdt.core.Signature; >@@ -53,6 +61,7 @@ > import com.sun.jdi.ReferenceType; > import com.sun.jdi.StackFrame; > import com.sun.jdi.Type; >+import com.sun.jdi.Value; > import com.sun.jdi.VirtualMachine; > > /** >@@ -61,6 +70,30 @@ > > public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { > >+ private static final String PARENT_SCOPED_PREFIX = "val$"; //$NON-NLS-1$ >+ >+ final class AnnonLocalVariable extends LocalVariableImpl { >+ private final FieldImpl f; >+ >+ private AnnonLocalVariable(VirtualMachineImpl vmImpl, MethodImpl method, long codeIndex, String name, >+ String signature, String genericSignature, int length, int slot, boolean isArgument, FieldImpl f) { >+ super(vmImpl, method, codeIndex, name, signature, genericSignature, length, slot, isArgument); >+ this.f = f; >+ } >+ >+ public boolean isThis() { >+ return false; >+ } >+ >+ public boolean isArgument() { >+ return false; >+ } >+ >+ Value actuallyGetValue() throws DebugException { >+ return getUnderlyingThisObject().getValue(f); >+ } >+ } >+ > /** > * This frame's depth in the call stack (0 == bottom of stack). > * A new frame is indicated by -2. >@@ -683,10 +716,37 @@ > } catch (RuntimeException e) { > targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2,new String[] {e.toString()}), e); > } >+ >+ List fields= getUnderlyingMethod().declaringType().fields(); >+ for (int i = 0; i < fields.size(); ++i) { >+ Object next= fields.get(i); >+ if (next instanceof FieldImpl) { >+ FieldImpl f= (FieldImpl) next; >+ >+ if (isParentScopedVariable(f)) { >+ variables.add(new AnnonLocalVariable(f.virtualMachineImpl(), (MethodImpl) getUnderlyingMethod(), >+ 0, washHiddenFieldName(f), f.signature(), f.genericSignature(), 0, >+ -1, false, f)); >+ } >+ } >+ } > return variables; > } > } > >+ >+ private boolean isParentScopedVariable(final FieldImpl f) { >+ final int mod= f.modifiers(); >+ return (mod & AccessibleImpl.MODIFIER_ACC_SYNTHETIC) != 0 && >+ (mod & AccessibleImpl.MODIFIER_ACC_FINAL) != 0 && >+ (mod & AccessibleImpl.MODIFIER_ACC_PRIVATE) != 0 && >+ f.name().startsWith(PARENT_SCOPED_PREFIX); >+ } >+ >+ private static String washHiddenFieldName(final FieldImpl f) { >+ return f.name().substring(PARENT_SCOPED_PREFIX.length()); >+ } >+ > /** > * Retrieves 'this' from the underlying stack frame. > * Returns <code>null</code> for static stack frames. >#P org.eclipse.jdt.debug.ui >Index: ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java,v >retrieving revision 1.53 >diff -u -r1.53 JavaDebugHover.java >--- ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java 14 Apr 2010 18:39:39 -0000 1.53 >+++ ui/org/eclipse/jdt/internal/debug/ui/JavaDebugHover.java 22 Jun 2010 21:33:00 -0000 >@@ -383,7 +383,12 @@ > } > } else { > // compare unresolved signatures >- if (((frame.isConstructor() && method.isConstructor()) || frame.getMethodName().equals(method.getElementName())) >+ // in an anonymous inner class, method is set to the class' parent here, >+ // so we can just check if it has any children to work out if we might >+ // be in an inner class, which makes it worth doing the deeper look. >+ // Alternatively, always do it (i.e. equal = true)? >+ if (method.getChildren().length != 0 || >+ ((frame.isConstructor() && method.isConstructor()) || frame.getMethodName().equals(method.getElementName())) > && frame.getDeclaringTypeName().endsWith(method.getDeclaringType().getElementName()) > && frame.getArgumentTypeNames().size() == method.getNumberOfParameters()) { > equal = true;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 317643
: 172466