mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 10:54:29 +02:00
Add more info to troubleshoot crashes related to LazyValue.getValue being null
This commit is contained in:
parent
a95d0a43a5
commit
3aad871652
@ -102,13 +102,16 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private T getNullableValue() {
|
protected T getNullableValue(boolean allowNull) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
try {
|
try {
|
||||||
if (evaluationContext == null) {
|
if (evaluationContext == null) {
|
||||||
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
|
final DebuggerContextImpl debuggerContext = DebuggerManagerEx.getInstanceEx(project).getContext();
|
||||||
evaluationContext = debuggerContext.createEvaluationContext();
|
evaluationContext = debuggerContext.createEvaluationContext();
|
||||||
if (evaluationContext == null) {
|
if (evaluationContext == null) {
|
||||||
|
if (!allowNull) {
|
||||||
|
throw new IllegalStateException("Can't create evaluation context");
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,6 +119,9 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
value = SmaliCodeFragmentFactory.evaluateRegister(evaluationContext, method, registerNumber, type);
|
value = SmaliCodeFragmentFactory.evaluateRegister(evaluationContext, method, registerNumber, type);
|
||||||
evaluationContext = null;
|
evaluationContext = null;
|
||||||
} catch (EvaluateException ex) {
|
} catch (EvaluateException ex) {
|
||||||
|
if (!allowNull) {
|
||||||
|
throw new IllegalStateException(ex);
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -124,7 +130,7 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
protected T getValue() {
|
protected T getValue() {
|
||||||
T value = getNullableValue();
|
T value = getNullableValue(false);
|
||||||
assert value != null;
|
assert value != null;
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
@ -154,7 +160,7 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean equals(Object obj) {
|
@Override public boolean equals(Object obj) {
|
||||||
Value value = getNullableValue();
|
Value value = getNullableValue(true);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return value.equals(obj);
|
return value.equals(obj);
|
||||||
}
|
}
|
||||||
@ -162,7 +168,7 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public int hashCode() {
|
@Override public int hashCode() {
|
||||||
Value value = getNullableValue();
|
Value value = getNullableValue(true);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return value.hashCode();
|
return value.hashCode();
|
||||||
}
|
}
|
||||||
@ -170,7 +176,7 @@ public class LazyValue<T extends Value> implements Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public String toString() {
|
@Override public String toString() {
|
||||||
Value value = getNullableValue();
|
Value value = getNullableValue(true);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return value.toString();
|
return value.toString();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user