- Notifications
You must be signed in to change notification settings - Fork 45
Fixed copyOf, copyOfRange and asList failures #1690
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
73f070b to f7ccac2 Compare | package org.utbot.engine.overrides.stream; | ||
| | ||
| import org.utbot.api.annotation.UtClassMock; | ||
| import org.utbot.api.mock.UtMock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Redundant?
| wrap(UtArrayList::class) { _, addr -> objectValue(LIST_TYPE, addr, ListWrapper(UT_ARRAY_LIST)) }, | ||
| wrap(UtLinkedList::class) { _, addr -> objectValue(LIST_TYPE, addr, ListWrapper(UT_LINKED_LIST)) }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are they have a list type here? In the wrappers above (e.g. UtStringBuilder and UtStringBuffer) you use concrete types instead of a common interface. Why?
| return MethodResult( | ||
| newArray, | ||
| memoryUpdates = arrayUpdateWithValue(newArray.addr, arrayType, selectArrayExpressionFromMemory(src)) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't get it. You just created a new array with all unbounded variables. Why is it a copy of the original one? Or you copied the whole original massive even though it might be bigger than a copy? If it is so, please, provide a corresponding comment here
| val to = parameters[2] as PrimitiveValue | ||
| | ||
| val originalLength = memory.findArrayLength(original.addr) | ||
| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a missed NPE check
| queuedSymbolicStateUpdates += mkNot(isFromBiggerThanTo).asHardConstraint() | ||
| | ||
| val newLength = Sub(to, from) | ||
| val newLengthValue = PrimitiveValue(IntType.v(), newLength) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newLength.toIntValue()
| internal val CLASS_REF_SOOT_CLASS: SootClass | ||
| get() = Scene.v().getSootClass(CLASS_REF_CLASSNAME) | ||
| internal val ARRAYS_SOOT_CLASS: SootClass | ||
| get() = Scene.v().getSootClass("java.util.Arrays") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please, use a java class and its name for consistency with the code below
f7ccac2 to 9cf6966 Compare
Description
Since real implementations of
Arrays.copyOfandArrays.copyOfRangeare pretty difficult (due to reflection usage) for the symbolic engine, symbolic implementations are added in this PR. Also, since the mock implementation ofArrays.asListreturns an instance of our classUtArrayList, some wrap hacks were added to prevent its appearance as a result of execution.Fixes #1699 .
Type of Change
How Has This Been Tested?
Automated Testing
org.utbot.examples.arrays.CopyOfExampleTestandorg.utbot.examples.collections.ListsPart3Test#testAsListExampleManual Scenario
org.antlr.v4.codegen.model.Recognizer.translateTokenStringsToTargetin Contest Estimator.Checklist (remove irrelevant options):