Skip to content

Commit

Permalink
Avoid error when executor assigns an id to a non-identified instance
Browse files Browse the repository at this point in the history
This allows executors called on a non-identified value to provide a new id for the instance, which might be a legit scenario now that we allow to match an executor regardless of the instance being identified or not
  • Loading branch information
capoz authored and mrjameshamilton committed Jun 20, 2024
1 parent aa063de commit be92778
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import proguard.evaluation.executor.Executor;
import proguard.evaluation.executor.MethodExecutionInfo;
import proguard.evaluation.executor.StringReflectionExecutor;
import proguard.evaluation.value.IdentifiedReferenceValue;
import proguard.evaluation.value.ReferenceValue;
import proguard.evaluation.value.Value;
import proguard.evaluation.value.ValueFactory;
Expand Down Expand Up @@ -294,13 +293,14 @@ private void applySideEffects(MethodResult result) {
}

private Optional<Value> getUpdatedInstance(MethodResult result) {
IdentifiedReferenceValue updatedInstance =
(IdentifiedReferenceValue) result.getUpdatedInstance();
if (!updatedInstance.isSpecific() || !parameters[0].isSpecific()) {
throw new IllegalStateException(
"An updated instance was provided but either it or the original instance are not specific");
}
if (!updatedInstance.id.equals(((IdentifiedReferenceValue) parameters[0]).id)) {
ReferenceValue updatedInstance = result.getUpdatedInstance();
ReferenceValue oldInstance = (ReferenceValue) parameters[0];
// We log an error if a new instance id is assigned, but it's allowed for the method call to
// assign a new id to a non-identified value
if (updatedInstance.isSpecific()
&& oldInstance.isSpecific()
&& !PartialEvaluatorUtils.getIdFromSpecificReferenceValue(updatedInstance)
.equals(PartialEvaluatorUtils.getIdFromSpecificReferenceValue(oldInstance))) {
log.error(
"The updated instance has unexpectedly a different identifier from the calling instance");
return Optional.empty();
Expand Down

0 comments on commit be92778

Please sign in to comment.