Add additional exception info if StringReference doesn't resolve to a String

This commit is contained in:
Ben Gruver 2016-10-23 13:55:23 -07:00
parent 8f7d1a897d
commit 7a95aa296f
2 changed files with 11 additions and 4 deletions

View File

@ -32,6 +32,8 @@
package org.jf.smalidea.debugging.value;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiSubstitutor;
import com.sun.jdi.ObjectReference;
import com.sun.jdi.StringReference;
import org.jf.smalidea.psi.impl.SmaliMethod;
@ -41,6 +43,11 @@ public class LazyStringReference extends LazyObjectReference<StringReference> im
}
public String value() {
ObjectReference objectReference = getValue();
if (!(objectReference instanceof StringReference)) {
throw new IllegalStateException(String.format("Expecting type String, but got %s. method=%s, register=%d",
objectReference.type().name(), this.method.getSignature(PsiSubstitutor.EMPTY), registerNumber));
}
return getValue().value();
}
}

View File

@ -48,10 +48,10 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class LazyValue<T extends Value> implements Value {
private final int registerNumber;
private final Project project;
private final SmaliMethod method;
private final String type;
protected final int registerNumber;
protected final Project project;
protected final SmaliMethod method;
protected final String type;
private EvaluationContext evaluationContext;
private Value value;