Skip to content

Commit

Permalink
Fix expression evaluation when toString() returns null
Browse files Browse the repository at this point in the history
  • Loading branch information
sharwell committed Feb 21, 2015
1 parent 9ecc977 commit ffdf127
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Tvl.Java.DebugInterface.Client/ObjectReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ public IStrongValueHandle<IValue> InvokeMethod(IThreadReference thread, IMethod
throw new NotImplementedException();
}

Value returnValueMirror = VirtualMachine.GetMirrorOf(returnValue);
if (returnValueMirror == null)
return null;

return new StrongValueHandle<Value>(VirtualMachine.GetMirrorOf(returnValue));
}

Expand Down
26 changes: 26 additions & 0 deletions Tvl.VisualStudio.Language.Java/Debugger/JavaDebugProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,32 @@ public int GetPropertyInfo(enum_DEBUGPROP_INFO_FLAGS dwFields, uint dwRadix, uin
displayValue = stringReference.GetValue();
}
}

if (displayValue == null)
{
IClassType objectClass = classType;
while (true)
{
IClassType parentClass = objectClass.GetSuperclass();
if (parentClass != null)
objectClass = parentClass;
else
break;
}

IMethod objectToStringMethod = objectClass.GetConcreteMethod("toString", "()Ljava/lang/String;");

// fall back to a non-virtual call
using (IStrongValueHandle<IValue> result = objectReference.InvokeMethod(null, objectToStringMethod, InvokeOptions.NonVirtual | InvokeOptions.SingleThreaded))
{
if (result != null)
{
stringReference = result.Value as IStringReference;
if (stringReference != null)
displayValue = stringReference.GetValue();
}
}
}
}

pPropertyInfo[0].bstrValue = "{" + displayValue + "}";
Expand Down

0 comments on commit ffdf127

Please sign in to comment.