Skip to content

Commit

Permalink
Add additional exception info if StringReference doesn't resolve to a…
Browse files Browse the repository at this point in the history
… String
  • Loading branch information
JesusFreke committed Oct 23, 2016
1 parent 8f7d1a8 commit 7a95aa2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -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;

Expand All @@ -41,6 +43,11 @@ public LazyStringReference(SmaliMethod method, Project project, int registerNumb
}

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();
}
}
Expand Up @@ -48,10 +48,10 @@
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;
Expand Down

0 comments on commit 7a95aa2

Please sign in to comment.