1 19 20 package org.netbeans.modules.debugger.jpda.models; 21 22 import com.sun.jdi.AbsentInformationException; 23 import com.sun.jdi.ClassNotLoadedException; 24 import com.sun.jdi.InvalidTypeException; 25 import com.sun.jdi.LocalVariable; 26 import com.sun.jdi.ObjectReference; 27 import com.sun.jdi.StackFrame; 28 import com.sun.jdi.Value; 29 import org.netbeans.api.debugger.jpda.InvalidExpressionException; 30 import org.netbeans.api.debugger.jpda.JPDAThread; 31 import org.netbeans.modules.debugger.jpda.JPDADebuggerImpl; 32 33 34 37 class Local extends AbstractVariable implements 38 org.netbeans.api.debugger.jpda.LocalVariable { 39 40 protected LocalVariable local; 41 JPDAThread thread; 42 int depth; 43 String className; 44 String genericSignature; 45 46 Local ( 47 JPDADebuggerImpl debugger, 48 Value value, 49 String className, 50 LocalVariable local, 51 CallStackFrameImpl frame 52 ) { 53 super ( 54 debugger, 55 value, 56 local.name () + local.hashCode() + 57 (value instanceof ObjectReference ? "^" : "") 58 ); 59 this.local = local; 60 if (frame != null) { 61 this.thread = frame.getThread(); 62 this.depth = frame.getFrameDepth(); 63 } 64 this.className = className; 65 } 66 67 Local ( 68 JPDADebuggerImpl debugger, 69 Value value, 70 String className, 71 LocalVariable local, 72 String genericSignature, 73 CallStackFrameImpl frame 74 ) { 75 super ( 76 debugger, 77 value, 78 genericSignature, 79 local.name () + local.hashCode() + 80 (value instanceof ObjectReference ? "^" : "") 81 ); 82 this.local = local; 83 if (frame != null) { 84 this.thread = frame.getThread(); 85 this.depth = frame.getFrameDepth(); 86 } 87 this.className = className; 88 this.genericSignature = genericSignature; 89 } 90 91 93 94 99 public String getName () { 100 return local.name (); 101 } 102 103 108 public String getClassName () { 109 return className; 110 } 111 112 protected final void setClassName(String className) { 113 this.className = className; 114 } 115 116 121 public String getDeclaredType () { 122 return local.typeName (); 123 } 124 125 protected final void setValue (Value value) throws InvalidExpressionException { 126 try { 127 StackFrame sf = ((CallStackFrameImpl) thread.getCallStack(depth, depth + 1)[0]).getStackFrame(); 128 sf.setValue (local, value); 129 } catch (AbsentInformationException aiex) { 130 throw new InvalidExpressionException(aiex); 131 } catch (InvalidTypeException ex) { 132 throw new InvalidExpressionException (ex); 133 } catch (ClassNotLoadedException ex) { 134 throw new InvalidExpressionException (ex); 135 } 136 } 137 138 140 final void setFrame(CallStackFrameImpl frame) { 141 this.thread = frame.getThread(); 142 this.depth = frame.getFrameDepth(); 143 } 144 145 public Local clone() { 146 Local clon; 147 if (genericSignature == null) { 148 clon = new Local(getDebugger(), getJDIValue(), className, local, null); 149 } else { 150 clon = new Local(getDebugger(), getJDIValue(), className, local, genericSignature, null); 151 } 152 clon.depth = this.depth; 153 clon.thread = this.thread; 154 return clon; 155 } 156 157 public String toString () { 158 return "LocalVariable " + local.name (); 159 } 160 } 161 | Popular Tags |