From f6bfc1696585dc8d15bcacb7aba64412dd84822a Mon Sep 17 00:00:00 2001 From: Carlo Alberto Pozzoli Date: Fri, 12 Apr 2024 17:13:03 +0200 Subject: [PATCH] Fix bugs in ExecutingInvocationUnit This fixes two bugs: - trying to retrieve an id from IdentifiedReferenceValue when the value could also be an IdentifiedArrayReferenceValue, so not castable - skipping the first parameter check in reflection executor (since now we are passing parameters without the instance) --- .../main/java/proguard/evaluation/ExecutingInvocationUnit.java | 2 +- .../java/proguard/evaluation/executor/ReflectionExecutor.java | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/base/src/main/java/proguard/evaluation/ExecutingInvocationUnit.java b/base/src/main/java/proguard/evaluation/ExecutingInvocationUnit.java index 827942e29..3d89a1ca4 100644 --- a/base/src/main/java/proguard/evaluation/ExecutingInvocationUnit.java +++ b/base/src/main/java/proguard/evaluation/ExecutingInvocationUnit.java @@ -419,7 +419,7 @@ private MethodResult createFallbackResult(MethodExecutionInfo methodInfo) { Object instanceId = null; if (instanceValue != null && instanceValue.isSpecific()) { - instanceId = ((IdentifiedReferenceValue) instanceValue).id; + instanceId = PartialEvaluatorUtils.getIdFromSpecificReferenceValue(instanceValue); } boolean returnsSameTypeAsInstance = methodInfo.returnsSameTypeAsInstance(); diff --git a/base/src/main/java/proguard/evaluation/executor/ReflectionExecutor.java b/base/src/main/java/proguard/evaluation/executor/ReflectionExecutor.java index 9930ffacb..0cd893516 100644 --- a/base/src/main/java/proguard/evaluation/executor/ReflectionExecutor.java +++ b/base/src/main/java/proguard/evaluation/executor/ReflectionExecutor.java @@ -93,12 +93,10 @@ private Optional createFallbackResultIfInvalidParameters( return Optional.of(createFallbackResultMethod(methodExecutionInfo, valueCalculator)); } - int paramOffset = methodExecutionInfo.isStatic() ? 0 : 1; if ((methodExecutionInfo.isInstanceMethod() && (!instance.isParticular() // NOSONAR instance can't be null for instance methods || isNonPreciseParticularValue(instance))) || methodExecutionInfo.getParameters().stream() - .skip(paramOffset) .anyMatch(value -> !value.isParticular() || isNonPreciseParticularValue(value))) { // All parameters must be particular and real objects to use reflection. Detailed arrays can // be converted to a real object if they are particular.