@@ -17,19 +17,27 @@ import org.usvm.instrumentation.testcase.descriptor.Descriptor2ValueConverter
17
17
import org.usvm.instrumentation.testcase.descriptor.UTestExceptionDescriptor
18
18
import org.usvm.instrumentation.util.enclosingClass
19
19
import org.usvm.instrumentation.util.enclosingMethod
20
+ import org.utbot.common.isPublic
20
21
import org.utbot.contest.usvm.executor.JcExecution
21
22
import org.utbot.framework.codegen.domain.builtin.UtilMethodProvider
23
+ import org.utbot.framework.plugin.api.ClassId
22
24
import org.utbot.framework.plugin.api.Coverage
23
25
import org.utbot.framework.plugin.api.EnvironmentModels
24
26
import org.utbot.framework.plugin.api.ExecutableId
25
27
import org.utbot.framework.plugin.api.Instruction
28
+ import org.utbot.framework.plugin.api.UtAssembleModel
29
+ import org.utbot.framework.plugin.api.UtExecutableCallModel
26
30
import org.utbot.framework.plugin.api.UtExecution
27
31
import org.utbot.framework.plugin.api.UtExecutionFailure
28
32
import org.utbot.framework.plugin.api.UtExecutionSuccess
29
33
import org.utbot.framework.plugin.api.UtExplicitlyThrownException
30
34
import org.utbot.framework.plugin.api.UtImplicitlyThrownException
31
35
import org.utbot.framework.plugin.api.UtInstrumentation
36
+ import org.utbot.framework.plugin.api.UtPrimitiveModel
32
37
import org.utbot.framework.plugin.api.UtVoidModel
38
+ import org.utbot.framework.plugin.api.mapper.UtModelDeepMapper
39
+ import org.utbot.framework.plugin.api.util.executableId
40
+ import org.utbot.framework.plugin.api.util.jClass
33
41
import org.utbot.framework.plugin.api.util.utContext
34
42
import org.utbot.fuzzer.IdGenerator
35
43
@@ -40,7 +48,7 @@ class JcToUtExecutionConverter(
40
48
private val jcClasspath : JcClasspath ,
41
49
private val idGenerator : IdGenerator <Int >,
42
50
private val instructionIdProvider : InstructionIdProvider ,
43
- utilMethodProvider : UtilMethodProvider ,
51
+ private val utilMethodProvider : UtilMethodProvider ,
44
52
) {
45
53
private val toValueConverter = Descriptor2ValueConverter (utContext.classLoader)
46
54
@@ -100,7 +108,41 @@ class JcToUtExecutionConverter(
100
108
}
101
109
} ? : return null
102
110
103
- return utUsvmExecution
111
+ return utUsvmExecution.mapModels(constructAssemblingMapper())
112
+ }
113
+
114
+ private fun constructAssemblingMapper (): UtModelDeepMapper = UtModelDeepMapper { model ->
115
+ // TODO usvm-sbft: support constructors with parameters here if it is really required
116
+ // Unfortunately, it is not possible to use [AssembleModelGeneral] as it requires soot being initialized.
117
+ if (model !is UtAssembleModel
118
+ || utilMethodProvider.createInstanceMethodId != model.instantiationCall.statement
119
+ || model.modificationsChain.isNotEmpty()) {
120
+ return @UtModelDeepMapper model
121
+ }
122
+
123
+ val instantiatingClassName = (model
124
+ .instantiationCall
125
+ .params
126
+ .single() as UtPrimitiveModel ).value.toString()
127
+
128
+ val defaultConstructor = ClassId (instantiatingClassName)
129
+ .jClass
130
+ .constructors
131
+ .firstOrNull { it.isPublic && it.parameters.isEmpty() }
132
+
133
+
134
+ defaultConstructor?.let { ctor ->
135
+ UtAssembleModel (
136
+ id = idGenerator.createId(),
137
+ classId = model.classId,
138
+ modelName = " " ,
139
+ instantiationCall = UtExecutableCallModel (
140
+ instance = null ,
141
+ executable = ctor.executableId,
142
+ params = emptyList(),
143
+ )
144
+ )
145
+ } ? : model
104
146
}
105
147
106
148
private fun convertException (exceptionDescriptor : UTestExceptionDescriptor ): Throwable =
0 commit comments