Skip to content

Commit

Permalink
Fix bugs in ExecutingInvocationUnit
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
capoz authored and Toon Willemot committed Apr 25, 2024
1 parent bd74a66 commit f6bfc16
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,10 @@ private Optional<MethodResult> 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.
Expand Down

0 comments on commit f6bfc16

Please sign in to comment.