diff options
Diffstat (limited to 'org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java')
-rw-r--r-- | org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java | 640 |
1 files changed, 379 insertions, 261 deletions
diff --git a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java index e3daea02d..8d774b8a1 100644 --- a/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java +++ b/org.eclipse.jdt.debug/model/org/eclipse/jdt/internal/debug/core/model/JDIStackFrame.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,19 +10,22 @@ *******************************************************************************/ 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.ValueImpl; @@ -62,12 +65,11 @@ import com.sun.jdi.VirtualMachine; public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { /** - * This frame's depth in the call stack (0 == bottom of stack). - * A new frame is indicated by -2. - * An invalid frame is indicated by -1. + * This frame's depth in the call stack (0 == bottom of stack). A new frame + * is indicated by -2. An invalid frame is indicated by -1. */ private int fDepth = -2; - + /** * Underlying JDI stack frame. */ @@ -80,35 +82,35 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { /** * Visible variables. */ - private List fVariables; + private List<IJavaVariable> fVariables; /** - * The underlying Object associated with this stack frame. - * Cached lazily on first access. + * The underlying Object associated with this stack frame. Cached lazily on + * first access. */ private ObjectReference fThisObject; /** - * The name of the type of the object that received the method call associated - * with this stack frame. Cached lazily on first access. + * The name of the type of the object that received the method call + * associated with this stack frame. Cached lazily on first access. */ private String fReceivingTypeName; /** * Whether the variables need refreshing */ - private boolean fRefreshVariables= true; + private boolean fRefreshVariables = true; /** - * Whether this stack frame has been marked as out of synch. If set - * to <code>true</code> this stack frame will stop dynamically - * calculating its out of synch state. + * Whether this stack frame has been marked as out of synch. If set to + * <code>true</code> this stack frame will stop dynamically calculating its + * out of synch state. */ - private boolean fIsOutOfSynch= false; - + private boolean fIsOutOfSynch = false; + /** * Whether local variable information was available */ private boolean fLocalsAvailable = true; - + /** * Location of this stack frame */ @@ -117,26 +119,31 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { /** * Creates a new stack frame in the given thread. * - * @param thread The parent JDI thread - * @param frame underlying frame - * @param depth depth on the stack (0 is bottom) + * @param thread + * The parent JDI thread + * @param frame + * underlying frame + * @param depth + * depth on the stack (0 is bottom) */ public JDIStackFrame(JDIThread thread, StackFrame frame, int depth) { - super((JDIDebugTarget)thread.getDebugTarget()); + super((JDIDebugTarget) thread.getDebugTarget()); setThread(thread); bind(frame, depth); } - + /** - * Binds this frame to the given underlying frame - * on the target VM or returns a new frame representing the - * given frame. A frame can only be re-bound to an underlying frame - * if it refers to the same depth on the stack in the same method. + * Binds this frame to the given underlying frame on the target VM or + * returns a new frame representing the given frame. A frame can only be + * re-bound to an underlying frame if it refers to the same depth on the + * stack in the same method. * - * @param frame underlying frame, or <code>null</code> - * @param depth depth in the call stack, or -1 to indicate the - * frame should become invalid - * @param return a frame to refer to the given frame or <code>null</code> + * @param frame + * underlying frame, or <code>null</code> + * @param depth + * depth in the call stack, or -1 to indicate the frame should + * become invalid + * @param return a frame to refer to the given frame or <code>null</code> */ protected JDIStackFrame bind(StackFrame frame, int depth) { synchronized (fThread) { @@ -156,8 +163,10 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { Method method = location.method(); if (method.equals(fLocation.method())) { try { - if (method.declaringType().defaultStratum().equals("Java") || //$NON-NLS-1$ - equals(getSourceName(location), getSourceName(fLocation))) { + if (method.declaringType().defaultStratum() + .equals("Java") || //$NON-NLS-1$ + equals(getSourceName(location), + getSourceName(fLocation))) { // TODO: what about receiving type being the same? fStackFrame = frame; fLocation = location; @@ -175,7 +184,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } } - + /** * @see IStackFrame#getThread() */ @@ -202,7 +211,8 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { */ public boolean canStepInto() { try { - return exists() && isTopStackFrame() && !isObsolete() && getThread().canStepInto(); + return exists() && isTopStackFrame() && !isObsolete() + && getThread().canStepInto(); } catch (DebugException e) { logError(e); return false; @@ -224,14 +234,14 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (!exists() || isObsolete() || !getThread().canStepReturn()) { return false; } - List frames = ((JDIThread)getThread()).computeStackFrames(); + List<IJavaStackFrame> frames = ((JDIThread) getThread()).computeStackFrames(); if (frames != null && !frames.isEmpty()) { boolean bottomFrame = this.equals(frames.get(frames.size() - 1)); - boolean aboveObsoleteFrame= false; + boolean aboveObsoleteFrame = false; if (!bottomFrame) { - int index= frames.indexOf(this); - if (index < frames.size() -1 && ((JDIStackFrame)frames.get(index + 1)).isObsolete()) { - aboveObsoleteFrame= true; + int index = frames.indexOf(this); + if (index < frames.size() - 1 && ((JDIStackFrame) frames.get(index + 1)).isObsolete()) { + aboveObsoleteFrame = true; } } return !bottomFrame && !aboveObsoleteFrame; @@ -256,49 +266,59 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { * @see IStackFrame#getVariables() */ public IVariable[] getVariables() throws DebugException { - List list = getVariables0(); - return (IVariable[])list.toArray(new IVariable[list.size()]); + List<IJavaVariable> list = getVariables0(); + return list.toArray(new IVariable[list.size()]); } - - protected List getVariables0() throws DebugException { + + protected List<IJavaVariable> getVariables0() throws DebugException { synchronized (fThread) { if (fVariables == null) { - - // throw exception if native method, so variable view will update + + // throw exception if native method, so variable view will + // update // with information message if (isNative()) { - requestFailed(JDIDebugModelMessages.JDIStackFrame_Variable_information_unavailable_for_native_methods, null); + requestFailed( + JDIDebugModelMessages.JDIStackFrame_Variable_information_unavailable_for_native_methods, + null); } - - Method method= getUnderlyingMethod(); - fVariables= new ArrayList(); - // #isStatic() does not claim to throw any exceptions - so it is not try/catch coded + + Method method = getUnderlyingMethod(); + fVariables = new ArrayList<IJavaVariable>(); + // #isStatic() does not claim to throw any exceptions - so it is + // not try/catch coded if (method.isStatic()) { // add statics - List allFields= null; + List<Field> allFields = null; ReferenceType declaringType = method.declaringType(); try { - allFields= declaringType.allFields(); + allFields = declaringType.allFields(); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_fields,new String[] {e.toString()}), e); - // execution will not reach this line, as - // #targetRequestFailed will throw an exception + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_fields, + e.toString()), e); + // execution will not reach this line, as + // #targetRequestFailed will throw an exception return Collections.EMPTY_LIST; } if (allFields != null) { - Iterator fields= allFields.iterator(); + Iterator<Field> fields = allFields.iterator(); while (fields.hasNext()) { - Field field= (Field) fields.next(); + Field field = fields.next(); if (field.isStatic()) { - fVariables.add(new JDIFieldVariable((JDIDebugTarget)getDebugTarget(), field, declaringType)); + fVariables.add(new JDIFieldVariable( + (JDIDebugTarget) getDebugTarget(), + field, declaringType)); } } - Collections.sort(fVariables, new Comparator() { - public int compare(Object a, Object b) { - JDIFieldVariable v1= (JDIFieldVariable)a; - JDIFieldVariable v2= (JDIFieldVariable)b; + Collections.sort(fVariables, new Comparator<IJavaVariable>() { + public int compare(IJavaVariable a, IJavaVariable b) { + JDIFieldVariable v1 = (JDIFieldVariable) a; + JDIFieldVariable v2 = (JDIFieldVariable) b; try { - return v1.getName().compareToIgnoreCase(v2.getName()); + return v1.getName().compareToIgnoreCase( + v2.getName()); } catch (DebugException de) { logError(de); return -1; @@ -308,15 +328,16 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } } else { // add "this" - ObjectReference t= getUnderlyingThisObject(); + ObjectReference t = getUnderlyingThisObject(); if (t != null) { - fVariables.add(new JDIThisVariable((JDIDebugTarget)getDebugTarget(), t)); + fVariables.add(new JDIThisVariable( + (JDIDebugTarget) getDebugTarget(), t)); } } // add locals - Iterator variables= getUnderlyingVisibleVariables().iterator(); + Iterator<LocalVariable> variables = getUnderlyingVisibleVariables().iterator(); while (variables.hasNext()) { - LocalVariable var= (LocalVariable) variables.next(); + LocalVariable var = variables.next(); fVariables.add(new JDILocalVariable(this, var)); } } else if (fRefreshVariables) { @@ -333,29 +354,34 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { public String getName() throws DebugException { return getMethodName(); } - + /** * @see IJavaStackFrame#getArgumentTypeNames() */ - public List getArgumentTypeNames() throws DebugException { + public List<String> getArgumentTypeNames() throws DebugException { try { - Method underlyingMethod= getUnderlyingMethod(); - String genericSignature= underlyingMethod.genericSignature(); + Method underlyingMethod = getUnderlyingMethod(); + String genericSignature = underlyingMethod.genericSignature(); if (genericSignature == null) { // no generic signature return underlyingMethod.argumentTypeNames(); } // generic signature - String[] parameterTypes= Signature.getParameterTypes(genericSignature); - List argumentTypeNames= new ArrayList(); - for (int i= 0; i < parameterTypes.length; i++) { - argumentTypeNames.add(Signature.toString(parameterTypes[i]).replace('/', '.')); + String[] parameterTypes = Signature + .getParameterTypes(genericSignature); + List<String> argumentTypeNames = new ArrayList<String>(); + for (String parameterType : parameterTypes) { + argumentTypeNames.add(Signature.toString(parameterType) + .replace('/', '.')); } return argumentTypeNames; } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_argument_type_names, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_argument_type_names, + e.toString()), e); // execution will never reach this line, as - // #targetRequestFailed will throw an exception + // #targetRequestFailed will throw an exception return null; } } @@ -369,7 +395,10 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return fLocation.lineNumber(); } catch (RuntimeException e) { if (getThread().isSuspended()) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number, + e.toString()), e); } } } @@ -417,7 +446,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (isTopStackFrame()) { getThread().stepOver(); } else { - ((JDIThread)getThread()).stepToFrame(this); + ((JDIThread) getThread()).stepToFrame(this); } } @@ -431,11 +460,11 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (isTopStackFrame()) { getThread().stepReturn(); } else { - List frames = ((JDIThread)getThread()).computeStackFrames(); + List<IJavaStackFrame> frames = ((JDIThread) getThread()).computeStackFrames(); int index = frames.indexOf(this); if (index >= 0 && index < frames.size() - 1) { - IStackFrame nextFrame = (IStackFrame)frames.get(index + 1); - ((JDIThread)getThread()).stepToFrame(nextFrame); + IStackFrame nextFrame = frames.get(index + 1); + ((JDIThread) getThread()).stepToFrame(nextFrame); } } } @@ -457,61 +486,70 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return; } - Method method= getUnderlyingMethod(); - int index= 0; + Method method = getUnderlyingMethod(); + int index = 0; if (!method.isStatic()) { // update "this" ObjectReference thisObject; - thisObject= getUnderlyingThisObject(); - JDIThisVariable oldThisObject= null; - if (!fVariables.isEmpty() && fVariables.get(0) instanceof JDIThisVariable) { - oldThisObject= (JDIThisVariable) fVariables.get(0); + thisObject = getUnderlyingThisObject(); + JDIThisVariable oldThisObject = null; + if (!fVariables.isEmpty() + && fVariables.get(0) instanceof JDIThisVariable) { + oldThisObject = (JDIThisVariable) fVariables.get(0); } if (thisObject == null && oldThisObject != null) { // removal of 'this' fVariables.remove(0); - index= 0; + index = 0; } else { if (oldThisObject == null && thisObject != null) { // creation of 'this' - oldThisObject= new JDIThisVariable((JDIDebugTarget)getDebugTarget(),thisObject); + oldThisObject = new JDIThisVariable( + (JDIDebugTarget) getDebugTarget(), thisObject); fVariables.add(0, oldThisObject); - index= 1; + index = 1; } else { if (oldThisObject != null) { - // 'this' still exists, replace with new 'this' if a different receiver + // 'this' still exists, replace with new 'this' if a + // different receiver if (!oldThisObject.retrieveValue().equals(thisObject)) { fVariables.remove(0); - fVariables.add(0, new JDIThisVariable((JDIDebugTarget)getDebugTarget(),thisObject)); + fVariables.add(0, new JDIThisVariable( + (JDIDebugTarget) getDebugTarget(), + thisObject)); } - index= 1; + index = 1; } } } } - List locals= null; + List<LocalVariable> locals = null; try { - locals= getUnderlyingStackFrame().visibleVariables(); + locals = getUnderlyingStackFrame().visibleVariables(); } catch (AbsentInformationException e) { - locals= Collections.EMPTY_LIST; + locals = Collections.EMPTY_LIST; } catch (NativeMethodException e) { - locals= Collections.EMPTY_LIST; + locals = Collections.EMPTY_LIST; } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables,new String[] {e.toString()}), e); - // execution will not reach this line, as - // #targetRequestFailed will throw an exception + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables, + e.toString()), e); + // execution will not reach this line, as + // #targetRequestFailed will throw an exception return; } - int localIndex= -1; + int localIndex = -1; while (index < fVariables.size()) { - Object var= fVariables.get(index); + Object var = fVariables.get(index); if (var instanceof JDILocalVariable) { - JDILocalVariable local= (JDILocalVariable) fVariables.get(index); - localIndex= locals.indexOf(local.getLocal()); + JDILocalVariable local = (JDILocalVariable) fVariables + .get(index); + localIndex = locals.indexOf(local.getLocal()); if (localIndex >= 0) { // update variable with new underling JDI LocalVariable - local.setLocal((LocalVariable) locals.get(localIndex)); + local.setLocal(locals.get(localIndex)); locals.remove(localIndex); index++; } else { @@ -519,65 +557,67 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { fVariables.remove(index); } } else { - //field variable of a static frame + // field variable of a static frame index++; } } // add any new locals - Iterator newOnes= locals.iterator(); + Iterator<LocalVariable> newOnes = locals.iterator(); while (newOnes.hasNext()) { - JDILocalVariable local= new JDILocalVariable(this, (LocalVariable) newOnes.next()); + JDILocalVariable local = new JDILocalVariable(this, newOnes.next()); fVariables.add(local); } } - - /** - * @see org.eclipse.debug.core.model.IDropToFrame#canDropToFrame() - */ - public boolean canDropToFrame() { - return supportsDropToFrame(); - } + + /** + * @see org.eclipse.debug.core.model.IDropToFrame#canDropToFrame() + */ + public boolean canDropToFrame() { + return supportsDropToFrame(); + } /** * @see IJavaStackFrame#supportsDropToFrame() */ public boolean supportsDropToFrame() { - JDIThread thread= (JDIThread) getThread(); - JDIDebugTarget target= (JDIDebugTarget)thread.getDebugTarget(); + JDIThread thread = (JDIThread) getThread(); + JDIDebugTarget target = (JDIDebugTarget) thread.getDebugTarget(); try { - if (!target.isAvailable() || !thread.isSuspended() || thread.isTerminated() || - thread.isInvokingMethod()) { + if (!target.isAvailable() || !thread.isSuspended() + || thread.isTerminated() || thread.isInvokingMethod()) { return false; - } - boolean j9Support= false; - boolean jdkSupport= target.canPopFrames(); + } + boolean j9Support = false; + boolean jdkSupport = target.canPopFrames(); VirtualMachine vm = getVM(); if (vm == null) { return false; } try { - j9Support= (thread.getUnderlyingThread() instanceof org.eclipse.jdi.hcr.ThreadReference) && - ((org.eclipse.jdi.hcr.VirtualMachine)vm).canDoReturn(); + j9Support = (thread.getUnderlyingThread() instanceof org.eclipse.jdi.hcr.ThreadReference) + && ((org.eclipse.jdi.hcr.VirtualMachine) vm) + .canDoReturn(); } catch (UnsupportedOperationException uoe) { - j9Support= false; + j9Support = false; } - + if (jdkSupport || j9Support) { // Also ensure that this frame and no frames above this // frame are native. Unable to pop native stack frames. - List frames= thread.computeStackFrames(); + List<IJavaStackFrame> frames = thread.computeStackFrames(); if (jdkSupport) { // JDK 1.4 VMs are currently unable to pop the bottom // stack frame. - if ((frames.size() > 0) && frames.get(frames.size() - 1) == this) { + if ((frames.size() > 0) + && frames.get(frames.size() - 1) == this) { return false; } } int index = 0; - JDIStackFrame frame= null; + JDIStackFrame frame = null; while (index < frames.size()) { - frame= (JDIStackFrame) frames.get(index); + frame = (JDIStackFrame) frames.get(index); index++; if (frame.isNative()) { return false; @@ -586,7 +626,9 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (jdkSupport) { // JDK 1.4 VMs are currently unable to pop the // frame directly above a native frame - if (index < frames.size() && ((JDIStackFrame)frames.get(index)).isNative()) { + if (index < frames.size() + && ((JDIStackFrame) frames.get(index)) + .isNative()) { return false; } } @@ -596,7 +638,8 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } return false; } catch (DebugException e) { - if (e.getStatus().getException() instanceof IncompatibleThreadStateException || e.getStatus().getCode() == IJavaThread.ERR_THREAD_NOT_SUSPENDED) { + if (e.getStatus().getException() instanceof IncompatibleThreadStateException + || e.getStatus().getCode() == IJavaThread.ERR_THREAD_NOT_SUSPENDED) { // if the thread has since resumed, drop is not supported return false; } @@ -618,7 +661,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (supportsDropToFrame()) { ((JDIThread) getThread()).dropToFrame(this); } else { - notSupported(JDIDebugModelMessages.JDIStackFrame_Drop_to_frame_not_supported); + notSupported(JDIDebugModelMessages.JDIStackFrame_Drop_to_frame_not_supported); } } @@ -626,7 +669,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (supportsDropToFrame()) { ((JDIThread) getThread()).popFrame(this); } else { - notSupported(JDIDebugModelMessages.JDIStackFrame_pop_frame_not_supported); + notSupported(JDIDebugModelMessages.JDIStackFrame_pop_frame_not_supported); } } @@ -638,22 +681,22 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return null; } IVariable[] variables = getVariables(); - IJavaVariable thisVariable= null; - for (int i = 0; i < variables.length; i++) { - IJavaVariable var = (IJavaVariable) variables[i]; + IJavaVariable thisVariable = null; + for (IVariable variable : variables) { + IJavaVariable var = (IJavaVariable) variable; if (var.getName().equals(varName)) { return var; } if (var instanceof JDIThisVariable) { // save for later - check for instance and static variables - thisVariable= var; + thisVariable = var; } } if (thisVariable != null) { IVariable[] thisChildren = thisVariable.getValue().getVariables(); - for (int i = 0; i < thisChildren.length; i++) { - IJavaVariable var= (IJavaVariable) thisChildren[i]; + for (IVariable element : thisChildren) { + IJavaVariable var = (IJavaVariable) element; if (var.getName().equals(varName)) { return var; } @@ -665,31 +708,33 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } /** - * Retrieves visible variables in this stack frame - * handling any exceptions. Returns an empty list if there are no - * variables. + * Retrieves visible variables in this stack frame handling any exceptions. + * Returns an empty list if there are no variables. * * @see JDIDebugElement#targetRequestFailed(String, RuntimeException) */ - protected List getUnderlyingVisibleVariables() throws DebugException { + protected List<LocalVariable> getUnderlyingVisibleVariables() throws DebugException { synchronized (fThread) { - List variables= Collections.EMPTY_LIST; + List<LocalVariable> variables = Collections.EMPTY_LIST; try { - variables= getUnderlyingStackFrame().visibleVariables(); + variables = getUnderlyingStackFrame().visibleVariables(); } catch (AbsentInformationException e) { setLocalsAvailable(false); } catch (NativeMethodException e) { setLocalsAvailable(false); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2,new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2, + e.toString()), e); } return variables; } } /** - * Retrieves 'this' from the underlying stack frame. - * Returns <code>null</code> for static stack frames. + * Retrieves 'this' from the underlying stack frame. Returns + * <code>null</code> for static stack frames. * * @see JDIDebugElement#targetRequestFailed(String, RuntimeException) */ @@ -699,26 +744,30 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { try { fThisObject = getUnderlyingStackFrame().thisObject(); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_this,new String[] {e.toString()}), e); - // execution will not reach this line, as - // #targetRequestFailed will throw an exception + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_this, + e.toString()), e); + // execution will not reach this line, as + // #targetRequestFailed will throw an exception return null; } } return fThisObject; } } - + /** * @see IAdaptable#getAdapter(Class) */ + @Override public Object getAdapter(Class adapter) { if (adapter == IJavaStackFrame.class || adapter == IJavaModifiers.class) { return this; } return super.getAdapter(adapter); } - + /** * @see IJavaStackFrame#getSignature() */ @@ -726,13 +775,16 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { try { return getUnderlyingMethod().signature(); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_method_signature, new String[] {e.toString()}), e); - // execution will not reach this line, as - // #targetRequestFailed will throw an exception + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_method_signature, + e.toString()), e); + // execution will not reach this line, as + // #targetRequestFailed will throw an exception return null; } } - + /** * @see IJavaStackFrame#getDeclaringTypeName() */ @@ -740,18 +792,22 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { synchronized (fThread) { try { if (isObsolete()) { - return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1; + return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1; } - return JDIReferenceType.getGenericName(getUnderlyingMethod().declaringType()); + return JDIReferenceType.getGenericName(getUnderlyingMethod() + .declaringType()); } catch (RuntimeException e) { if (getThread().isSuspended()) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_declaring_type, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_declaring_type, + e.toString()), e); } - return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1; + return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1; } } } - + /** * @see IJavaStackFrame#getReceivingTypeName() */ @@ -759,128 +815,135 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (fStackFrame == null || fReceivingTypeName == null) { try { if (isObsolete()) { - fReceivingTypeName=JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2; + fReceivingTypeName = JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2; } else { ObjectReference thisObject = getUnderlyingThisObject(); if (thisObject == null) { fReceivingTypeName = getDeclaringTypeName(); } else { - fReceivingTypeName = JDIReferenceType.getGenericName(thisObject.referenceType()); + fReceivingTypeName = JDIReferenceType + .getGenericName(thisObject.referenceType()); } } } catch (RuntimeException e) { if (getThread().isSuspended()) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_receiving_type, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_receiving_type, + e.toString()), e); } - return JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2; + return JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2; } } return fReceivingTypeName; } - + /** * @see IJavaStackFrame#getMethodName() */ public String getMethodName() throws DebugException { try { - return getUnderlyingMethod().name(); + return getUnderlyingMethod().name(); } catch (RuntimeException e) { if (getThread().isSuspended()) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_method_name, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_method_name, + e.toString()), e); } - return JDIDebugModelMessages.JDIStackFrame__unknown_method__1; + return JDIDebugModelMessages.JDIStackFrame__unknown_method__1; } } - + /** * @see IJavaStackFrame#isNative() */ public boolean isNative() throws DebugException { return getUnderlyingMethod().isNative(); } - + /** * @see IJavaStackFrame#isConstructor() */ public boolean isConstructor() throws DebugException { return getUnderlyingMethod().isConstructor(); } - + /** * @see IJavaStackFrame#isStaticInitializer() */ public boolean isStaticInitializer() throws DebugException { return getUnderlyingMethod().isStaticInitializer(); } - + /** * @see IJavaModifiers#isFinal() */ public boolean isFinal() throws DebugException { return getUnderlyingMethod().isFinal(); } - + /** * @see IJavaStackFrame#isSynchronized() */ public boolean isSynchronized() throws DebugException { return getUnderlyingMethod().isSynchronized(); } - + /** * @see IJavaModifiers#isSynthetic() */ public boolean isSynthetic() throws DebugException { return getUnderlyingMethod().isSynthetic(); } - + /** * @see IJavaModifiers#isPublic() */ public boolean isPublic() throws DebugException { return getUnderlyingMethod().isPublic(); } - + /** * @see IJavaModifiers#isPrivate() */ public boolean isPrivate() throws DebugException { return getUnderlyingMethod().isPrivate(); } - + /** * @see IJavaModifiers#isProtected() */ public boolean isProtected() throws DebugException { return getUnderlyingMethod().isProtected(); } - + /** * @see IJavaModifiers#isPackagePrivate() */ public boolean isPackagePrivate() throws DebugException { return getUnderlyingMethod().isPackagePrivate(); } - + /** * @see IJavaModifiers#isStatic() */ public boolean isStatic() throws DebugException { return getUnderlyingMethod().isStatic(); } - + /** * @see IJavaStackFrame#getSourceName() */ public String getSourceName() throws DebugException { synchronized (fThread) { - return getSourceName(fLocation); + return getSourceName(fLocation); } } - + /** - * Returns the source from the default stratum of the given location - * or <code>null</code> if not available (missing attribute). + * Returns the source from the default stratum of the given location or + * <code>null</code> if not available (missing attribute). */ private String getSourceName(Location location) throws DebugException { try { @@ -890,11 +953,14 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } catch (NativeMethodException e) { return null; } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name, + e.toString()), e); } return null; - } - + } + private boolean equals(Object o1, Object o2) { if (o1 == null) { return o2 == null; @@ -902,21 +968,21 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return o1.equals(o2); } } - + protected boolean isTopStackFrame() throws DebugException { IStackFrame tos = getThread().getTopStackFrame(); return tos != null && tos.equals(this); } - + /** - * Sets this stack frame to be out of synch. - * Note that passing <code>true</code> to this method - * marks this stack frame as out of synch permanently (statically). + * Sets this stack frame to be out of synch. Note that passing + * <code>true</code> to this method marks this stack frame as out of synch + * permanently (statically). */ public void setOutOfSynch(boolean outOfSynch) { - fIsOutOfSynch= outOfSynch; + fIsOutOfSynch = outOfSynch; } - + /** * @see IJavaStackFrame#isOutOfSynch() */ @@ -927,19 +993,22 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { // if this frame's thread is not suspended, the out-of-synch info cannot // change until it suspends again if (getThread().isSuspended()) { - JDIDebugTarget target= (JDIDebugTarget)getDebugTarget(); - if (target.hasHCROccurred() && target.isOutOfSynch(getUnderlyingMethod().declaringType().name())) { + JDIDebugTarget target = (JDIDebugTarget) getDebugTarget(); + if (target.hasHCROccurred() + && target.isOutOfSynch(getUnderlyingMethod() + .declaringType().name())) { return true; } } return false; } - + /** * @see IJavaStackFrame#isObsolete() */ public boolean isObsolete() { - if (!JDIDebugPlugin.isJdiVersionGreaterThanOrEqual(new int[] {1,4}) || !((JDIDebugTarget)getDebugTarget()).hasHCROccurred()) { + if (!JDIDebugPlugin.isJdiVersionGreaterThanOrEqual(new int[] { 1, 4 }) + || !((JDIDebugTarget) getDebugTarget()).hasHCROccurred()) { // If no hot code replace has occurred, this frame // cannot be obsolete. return false; @@ -953,18 +1022,19 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return false; } } - + protected boolean exists() { synchronized (fThread) { return fDepth != -1; } } - + /** * @see ITerminate#canTerminate() */ public boolean canTerminate() { - return exists() && getThread().canTerminate() || getDebugTarget().canTerminate(); + return exists() && getThread().canTerminate() + || getDebugTarget().canTerminate(); } /** @@ -984,41 +1054,51 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { getDebugTarget().terminate(); } } - + /** * Returns this stack frame's underlying JDI frame. * - * @exception DebugException if this stack frame does - * not currently have an underlying frame (is in an - * interim state where this frame's thread has been - * resumed, and is not yet suspended). + * @exception DebugException + * if this stack frame does not currently have an underlying + * frame (is in an interim state where this frame's thread + * has been resumed, and is not yet suspended). */ protected StackFrame getUnderlyingStackFrame() throws DebugException { synchronized (fThread) { if (fStackFrame == null) { if (fDepth == -1) { - throw new DebugException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IJavaStackFrame.ERR_INVALID_STACK_FRAME, JDIDebugModelMessages.JDIStackFrame_25, null)); + throw new DebugException(new Status(IStatus.ERROR, + JDIDebugPlugin.getUniqueIdentifier(), + IJavaStackFrame.ERR_INVALID_STACK_FRAME, + JDIDebugModelMessages.JDIStackFrame_25, null)); } if (fThread.isSuspended()) { // re-index stack frames - See Bug 47198 fThread.computeStackFrames(); if (fDepth == -1) { // If depth is -1, then this is an invalid frame - throw new DebugException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IJavaStackFrame.ERR_INVALID_STACK_FRAME, JDIDebugModelMessages.JDIStackFrame_25, null)); + throw new DebugException(new Status(IStatus.ERROR, + JDIDebugPlugin.getUniqueIdentifier(), + IJavaStackFrame.ERR_INVALID_STACK_FRAME, + JDIDebugModelMessages.JDIStackFrame_25, null)); } } else { - throw new DebugException(new Status(IStatus.ERROR, JDIDebugPlugin.getUniqueIdentifier(), IJavaThread.ERR_THREAD_NOT_SUSPENDED, JDIDebugModelMessages.JDIStackFrame_25, null)); + throw new DebugException(new Status(IStatus.ERROR, + JDIDebugPlugin.getUniqueIdentifier(), + IJavaThread.ERR_THREAD_NOT_SUSPENDED, + JDIDebugModelMessages.JDIStackFrame_25, null)); } } return fStackFrame; } } - + /** - * Sets the underlying JDI StackFrame. Called by a thread - * when incrementally updating after a step has completed. + * Sets the underlying JDI StackFrame. Called by a thread when incrementally + * updating after a step has completed. * - * @param frame The underlying stack frame + * @param frame + * The underlying stack frame */ protected void setUnderlyingStackFrame(StackFrame frame) { synchronized (fThread) { @@ -1028,23 +1108,23 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } } } - + protected void setThread(JDIThread thread) { fThread = thread; } - protected void setVariables(List variables) { + protected void setVariables(List<IJavaVariable> variables) { fVariables = variables; } - + /** * @see IJavaStackFrame#getLocalVariables() */ public IJavaVariable[] getLocalVariables() throws DebugException { - List list = getUnderlyingVisibleVariables(); + List<LocalVariable> list = getUnderlyingVisibleVariables(); IJavaVariable[] locals = new IJavaVariable[list.size()]; for (int i = 0; i < list.size(); i++) { - locals[i] = new JDILocalVariable(this, (LocalVariable)list.get(i)); + locals[i] = new JDILocalVariable(this, list.get(i)); } return locals; } @@ -1057,7 +1137,8 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (!isStatic()) { ObjectReference thisObject = getUnderlyingThisObject(); if (thisObject != null) { - receiver = (IJavaObject)JDIValue.createValue((JDIDebugTarget)getDebugTarget(), thisObject); + receiver = (IJavaObject) JDIValue.createValue( + (JDIDebugTarget) getDebugTarget(), thisObject); } } return receiver; @@ -1080,28 +1161,38 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { try { Type type = method.declaringType(); if (type instanceof ClassType) { - return (IJavaClassType)JDIType.createType((JDIDebugTarget)getDebugTarget(), type); + return (IJavaClassType) JDIType.createType( + (JDIDebugTarget) getDebugTarget(), type); } targetRequestFailed(JDIDebugModelMessages.JDIStackFrame_0, null); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retreiving_declaring_type, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retreiving_declaring_type, + e.toString()), e); } return null; } - - /* (non-Javadoc) + + /* + * (non-Javadoc) + * * @see org.eclipse.jdt.debug.core.IJavaStackFrame#getReferenceType() */ public IJavaReferenceType getReferenceType() throws DebugException { Method method = getUnderlyingMethod(); try { Type type = method.declaringType(); - return (IJavaReferenceType)JDIType.createType((JDIDebugTarget)getDebugTarget(), type); + return (IJavaReferenceType) JDIType.createType( + (JDIDebugTarget) getDebugTarget(), type); } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retreiving_declaring_type, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retreiving_declaring_type, + e.toString()), e); } return null; - } + } /** * Expression level stepping not supported. @@ -1122,36 +1213,36 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } /** - * Clears the cached data of this stack frame. - * The underlying stack frame has changed in such a way - * that the cached data may not be valid. + * Clears the cached data of this stack frame. The underlying stack frame + * has changed in such a way that the cached data may not be valid. */ private void clearCachedData() { - fThisObject= null; - fReceivingTypeName= null; + fThisObject = null; + fReceivingTypeName = null; } - + /** * @see IJavaStackFrame#wereLocalsAvailable() */ public boolean wereLocalsAvailable() { return fLocalsAvailable; } - + /** - * Sets whether locals were available. If the setting is - * not the same as the current value, a change event is - * fired such that a UI client can update. + * Sets whether locals were available. If the setting is not the same as the + * current value, a change event is fired such that a UI client can update. * - * @param available whether local variable information is - * available for this stack frame. + * @param available + * whether local variable information is available for this stack + * frame. */ private void setLocalsAvailable(boolean available) { if (available != fLocalsAvailable) { fLocalsAvailable = available; fireChangeEvent(DebugEvent.STATE); } - } + } + /** * @see IStackFrame#hasRegisterGroups() */ @@ -1181,7 +1272,7 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { * @see org.eclipse.debug.core.model.IFilteredStep#stepWithFilters() */ public void stepWithFilters() throws DebugException { - ((IJavaThread)getThread()).stepWithFilters(); + ((IJavaThread) getThread()).stepWithFilters(); } /** @@ -1193,12 +1284,15 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return fLocation.sourcePath(stratum); } catch (AbsentInformationException e) { } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path, + e.toString()), e); } } return null; } - + /** * @see org.eclipse.jdt.debug.core.IJavaStackFrame#getSourcePath() */ @@ -1208,14 +1302,19 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return fLocation.sourcePath(); } catch (AbsentInformationException e) { } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path, + e.toString()), e); } } return null; - } + } /* - * @see org.eclipse.jdt.debug.core.IJavaStackFrame#getLineNumber(java.lang.String) + * @see + * org.eclipse.jdt.debug.core.IJavaStackFrame#getLineNumber(java.lang.String + * ) */ public int getLineNumber(String stratum) throws DebugException { synchronized (fThread) { @@ -1223,7 +1322,10 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return fLocation.lineNumber(stratum); } catch (RuntimeException e) { if (getThread().isSuspended()) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number, + e.toString()), e); } } } @@ -1231,7 +1333,9 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } /* - * @see org.eclipse.jdt.debug.core.IJavaStackFrame#getSourceName(java.lang.String) + * @see + * org.eclipse.jdt.debug.core.IJavaStackFrame#getSourceName(java.lang.String + * ) */ public String getSourceName(String stratum) throws DebugException { synchronized (fThread) { @@ -1240,20 +1344,27 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { } catch (AbsentInformationException e) { } catch (NativeMethodException e) { } catch (RuntimeException e) { - targetRequestFailed(MessageFormat.format(JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name, new String[] {e.toString()}), e); + targetRequestFailed( + MessageFormat.format( + JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name, + e.toString()), e); } } return null; } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jdt.debug.core.IJavaStackFrame#isVarargs() */ public boolean isVarArgs() throws DebugException { return getUnderlyingMethod().isVarArgs(); } - /* (non-Javadoc) + /* + * (non-Javadoc) + * * @see org.eclipse.jdt.debug.core.IJavaStackFrame#canForceReturn() */ public boolean canForceReturn() { @@ -1263,10 +1374,11 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { if (isTopStackFrame()) { return true; } else { - List frames= fThread.computeStackFrames(); + List<IJavaStackFrame> frames = fThread.computeStackFrames(); int index = frames.indexOf(this); if (index > 0) { - JDIStackFrame prev = (JDIStackFrame) frames.get(index - 1); + JDIStackFrame prev = (JDIStackFrame) frames + .get(index - 1); return prev.canDropToFrame(); } } @@ -1277,8 +1389,12 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { return false; } - /* (non-Javadoc) - * @see org.eclipse.jdt.debug.core.IJavaStackFrame#forceReturn(org.eclipse.jdt.debug.core.IJavaValue) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.jdt.debug.core.IJavaStackFrame#forceReturn(org.eclipse.jdt + * .debug.core.IJavaValue) */ public void forceReturn(IJavaValue value) throws DebugException { if (isTopStackFrame()) { @@ -1287,13 +1403,15 @@ public class JDIStackFrame extends JDIDebugElement implements IJavaStackFrame { // first check assignment compatible Method method = getUnderlyingMethod(); try { - ValueImpl.checkValue(((JDIValue)value).getUnderlyingValue(), method.returnType(), (VirtualMachineImpl) method.virtualMachine()); + ValueImpl.checkValue(((JDIValue) value).getUnderlyingValue(), + method.returnType(), + (VirtualMachineImpl) method.virtualMachine()); } catch (InvalidTypeException e) { targetRequestFailed(JDIDebugModelMessages.JDIStackFrame_26, e); } catch (ClassNotLoadedException e) { targetRequestFailed(JDIDebugModelMessages.JDIThread_48, e); } - List frames= fThread.computeStackFrames(); + List<IJavaStackFrame> frames = fThread.computeStackFrames(); int index = frames.indexOf(this); if (index > 0) { JDIStackFrame prev = (JDIStackFrame) frames.get(index - 1); |