@@ -60,10 +60,10 @@ import org.utbot.framework.plugin.api.UtNullModel
60
60
import org.utbot.framework.plugin.api.UtOverflowFailure
61
61
import org.utbot.framework.plugin.api.UtResult
62
62
import org.utbot.framework.plugin.api.UtSymbolicExecution
63
- import org.utbot.framework.plugin.api.id
64
63
import org.utbot.framework.plugin.api.onSuccess
65
64
import org.utbot.framework.plugin.api.util.description
66
65
import org.utbot.framework.plugin.api.util.id
66
+ import org.utbot.framework.plugin.api.util.isConstructor
67
67
import org.utbot.framework.plugin.api.util.isEnum
68
68
import org.utbot.framework.plugin.api.util.utContext
69
69
import org.utbot.framework.plugin.api.util.voidClassId
@@ -85,7 +85,6 @@ import org.utbot.fuzzer.fuzz
85
85
import org.utbot.fuzzer.providers.ObjectModelProvider
86
86
import org.utbot.fuzzer.withMutations
87
87
import org.utbot.instrumentation.ConcreteExecutor
88
- import soot.SootMethod
89
88
import soot.jimple.Stmt
90
89
import soot.tagkit.ParamNamesTag
91
90
import java.lang.reflect.Method
@@ -154,16 +153,14 @@ private fun pathSelector(graph: InterProceduralUnitGraph, typeRegistry: TypeRegi
154
153
155
154
class UtBotSymbolicEngine (
156
155
private val controller : EngineController ,
157
- private val executableId : ExecutableId ,
156
+ private val methodUnderTest : ExecutableId ,
158
157
classpath : String ,
159
158
dependencyPaths : String ,
160
159
mockStrategy : MockStrategy = NO_MOCKS ,
161
160
chosenClassesToMockAlways : Set <ClassId >,
162
161
private val solverTimeoutInMillis : Int = checkSolverTimeoutMillis
163
162
) : UtContextInitializer() {
164
- private val methodUnderTest = executableId.sootMethod
165
-
166
- private val graph = methodUnderTest.jimpleBody().apply {
163
+ private val graph = methodUnderTest.sootMethod.jimpleBody().apply {
167
164
logger.trace { " JIMPLE for $methodUnderTest :\n $this " }
168
165
}.graph()
169
166
@@ -177,7 +174,7 @@ class UtBotSymbolicEngine(
177
174
// TODO HACK violation of encapsulation
178
175
internal val typeResolver: TypeResolver = TypeResolver (typeRegistry, hierarchy)
179
176
180
- private val classUnderTest: ClassId = methodUnderTest.declaringClass.id
177
+ private val classUnderTest: ClassId = methodUnderTest.classId
181
178
182
179
private val mocker: Mocker = Mocker (
183
180
mockStrategy,
@@ -384,7 +381,7 @@ class UtBotSymbolicEngine(
384
381
* @param modelProvider provides model values for a method
385
382
*/
386
383
fun fuzzing (until : Long = Long .MAX_VALUE , modelProvider : (ModelProvider ) -> ModelProvider = { it }) = flow {
387
- val isFuzzable = executableId .parameters.all { classId ->
384
+ val isFuzzable = methodUnderTest .parameters.all { classId ->
388
385
classId != Method ::class .java.id && // causes the child process crash at invocation
389
386
classId != Class ::class .java.id // causes java.lang.IllegalAccessException: java.lang.Class at sun.misc.Unsafe.allocateInstance(Native Method)
390
387
}
@@ -417,8 +414,8 @@ class UtBotSymbolicEngine(
417
414
}
418
415
}
419
416
420
- val methodUnderTestDescription = FuzzedMethodDescription (executableId , collectConstantsForFuzzer(graph)).apply {
421
- compilableName = if (! methodUnderTest.isConstructor) executableId .name else null
417
+ val methodUnderTestDescription = FuzzedMethodDescription (methodUnderTest , collectConstantsForFuzzer(graph)).apply {
418
+ compilableName = if (! methodUnderTest.isConstructor) methodUnderTest .name else null
422
419
className = classUnderTest.simpleName
423
420
packageName = classUnderTest.packageName
424
421
val names = graph.body.method.tags.filterIsInstance<ParamNamesTag >().firstOrNull()?.names
@@ -428,7 +425,7 @@ class UtBotSymbolicEngine(
428
425
val coveredInstructionValues = linkedMapOf<Trie .Node <Instruction >, List <FuzzedValue >>()
429
426
var attempts = 0
430
427
val attemptsLimit = UtSettings .fuzzingMaxAttempts
431
- val hasMethodUnderTestParametersToFuzz = executableId .parameters.isNotEmpty()
428
+ val hasMethodUnderTestParametersToFuzz = methodUnderTest .parameters.isNotEmpty()
432
429
val fuzzedValues = if (hasMethodUnderTestParametersToFuzz) {
433
430
fuzz(methodUnderTestDescription, modelProvider(defaultModelProviders(defaultIdGenerator)))
434
431
} else {
@@ -627,7 +624,7 @@ class UtBotSymbolicEngine(
627
624
}
628
625
}
629
626
630
- private fun ResolvedModels.constructStateForMethod (methodUnderTest : SootMethod ): EnvironmentModels {
627
+ private fun ResolvedModels.constructStateForMethod (methodUnderTest : ExecutableId ): EnvironmentModels {
631
628
val (thisInstanceBefore, paramsBefore) = when {
632
629
methodUnderTest.isStatic -> null to parameters
633
630
methodUnderTest.isConstructor -> null to parameters.drop(1 )
@@ -637,15 +634,15 @@ private fun ResolvedModels.constructStateForMethod(methodUnderTest: SootMethod):
637
634
}
638
635
639
636
private suspend fun ConcreteExecutor <UtConcreteExecutionResult , UtExecutionInstrumentation >.executeConcretely (
640
- methodUnderTest : SootMethod ,
637
+ methodUnderTest : ExecutableId ,
641
638
stateBefore : EnvironmentModels ,
642
639
instrumentation : List <UtInstrumentation >
643
640
): UtConcreteExecutionResult = executeAsync(
644
- methodUnderTest.declaringClass .name,
645
- methodUnderTest.pureJavaSignature ,
641
+ methodUnderTest.classId .name,
642
+ methodUnderTest.signature ,
646
643
arrayOf(),
647
644
parameters = UtConcreteExecutionData (stateBefore, instrumentation)
648
- ).convertToAssemble(methodUnderTest)
645
+ ).convertToAssemble(methodUnderTest.classId.packageName )
649
646
650
647
/* *
651
648
* Before pushing our states for concrete execution, we have to be sure that every state is consistent.
0 commit comments