1
1
package org.utbot.framework.util
2
2
3
- import org.utbot.api.mock.UtMock
4
3
import org.utbot.common.FileUtil
5
- import org.utbot.engine.UtNativeStringWrapper
6
4
import org.utbot.engine.jimpleBody
7
- import org.utbot.engine.overrides.Boolean
8
- import org.utbot.engine.overrides.Byte
9
- import org.utbot.engine.overrides.Character
10
- import org.utbot.engine.overrides.Class
11
- import org.utbot.engine.overrides.Integer
12
- import org.utbot.engine.overrides.Long
13
- import org.utbot.engine.overrides.PrintStream
14
- import org.utbot.engine.overrides.Short
15
- import org.utbot.engine.overrides.System
16
- import org.utbot.engine.overrides.UtArrayMock
17
- import org.utbot.engine.overrides.UtLogicMock
18
- import org.utbot.engine.overrides.UtOverrideMock
19
- import org.utbot.engine.overrides.collections.AbstractCollection
20
- import org.utbot.engine.overrides.collections.AssociativeArray
21
- import org.utbot.engine.overrides.collections.Collection
22
- import org.utbot.engine.overrides.collections.List as UtList
23
- import org.utbot.engine.overrides.collections.RangeModifiableUnlimitedArray
24
- import org.utbot.engine.overrides.collections.UtArrayList
25
- import org.utbot.engine.overrides.collections.UtGenericAssociative
26
- import org.utbot.engine.overrides.collections.UtGenericStorage
27
- import org.utbot.engine.overrides.collections.UtHashMap
28
- import org.utbot.engine.overrides.collections.UtHashSet
29
- import org.utbot.engine.overrides.collections.UtLinkedList
30
- import org.utbot.engine.overrides.collections.UtLinkedListWithNullableCheck
31
- import org.utbot.engine.overrides.collections.UtOptional
32
- import org.utbot.engine.overrides.collections.UtOptionalDouble
33
- import org.utbot.engine.overrides.collections.UtOptionalInt
34
- import org.utbot.engine.overrides.collections.UtOptionalLong
35
- import org.utbot.engine.overrides.stream.Arrays
36
- import org.utbot.engine.overrides.stream.Stream
37
- import org.utbot.engine.overrides.stream.UtStream
38
- import org.utbot.engine.overrides.strings.UtString
39
- import org.utbot.engine.overrides.strings.UtStringBuffer
40
- import org.utbot.engine.overrides.strings.UtStringBuilder
41
5
import org.utbot.engine.pureJavaSignature
42
6
import org.utbot.framework.plugin.api.ExecutableId
43
7
import org.utbot.framework.plugin.services.JdkInfo
@@ -60,7 +24,7 @@ object SootUtils {
60
24
* code.
61
25
* @param forceReload forces to reinitialize Soot even if the [previousBuildDirs] equals to the class buildDir.
62
26
*/
63
- fun runSoot (clazz : java.lang. Class <* >, forceReload : kotlin. Boolean , jdkInfo : JdkInfo ) {
27
+ fun runSoot (clazz : Class <* >, forceReload : Boolean , jdkInfo : JdkInfo ) {
64
28
val buildDir = FileUtil .locateClassPath(clazz) ? : FileUtil .isolateClassFiles(clazz)
65
29
val buildDirPath = buildDir.toPath()
66
30
@@ -74,7 +38,7 @@ object SootUtils {
74
38
* @param forceReload forces to reinitialize Soot even if the [previousBuildDirs] equals to [buildDirPaths] and
75
39
* [previousClassPath] equals to [classPath].
76
40
*/
77
- fun runSoot (buildDirPaths : List <Path >, classPath : String? , forceReload : kotlin. Boolean , jdkInfo : JdkInfo ) {
41
+ fun runSoot (buildDirPaths : List <Path >, classPath : String? , forceReload : Boolean , jdkInfo : JdkInfo ) {
78
42
synchronized(this ) {
79
43
if (buildDirPaths != previousBuildDirs || classPath != previousClassPath || forceReload) {
80
44
initSoot(buildDirPaths, classPath, jdkInfo)
@@ -107,7 +71,7 @@ private fun initSoot(buildDirs: List<Path>, classpath: String?, jdkInfo: JdkInfo
107
71
+ if (! classpath.isNullOrEmpty()) File .pathSeparator + " $classpath " else " "
108
72
)
109
73
set_src_prec(Options .src_prec_only_class)
110
- set_process_dir(buildDirs.map { " $it " })
74
+ set_process_dir(buildDirs.map { it.toString() })
111
75
set_keep_line_number(true )
112
76
set_ignore_classpath_errors(true ) // gradle/build/resources/main does not exists, but it's not a problem
113
77
set_output_format(Options .output_format_jimple)
@@ -143,60 +107,60 @@ fun jimpleBody(method: ExecutableId): JimpleBody =
143
107
method.sootMethod.jimpleBody()
144
108
145
109
146
- private fun addBasicClasses (vararg classes : java.lang. Class <* >) {
110
+ private fun addBasicClasses (vararg classes : Class <* >) {
147
111
classes.forEach {
148
112
Scene .v().addBasicClass(it.name, SootClass .BODIES )
149
113
}
150
114
}
151
115
152
116
private val classesToLoad = arrayOf(
153
- AbstractCollection ::class ,
154
- UtMock ::class ,
155
- UtOverrideMock ::class ,
156
- UtLogicMock ::class ,
157
- UtArrayMock ::class ,
158
- Boolean ::class ,
159
- Byte ::class ,
160
- Character ::class ,
161
- Class ::class ,
162
- Integer ::class ,
163
- Long ::class ,
164
- Short ::class ,
165
- System ::class ,
166
- UtOptional ::class ,
167
- UtOptionalInt ::class ,
168
- UtOptionalLong ::class ,
169
- UtOptionalDouble ::class ,
170
- UtArrayList ::class ,
171
- UtArrayList .UtArrayListIterator ::class ,
172
- UtLinkedList ::class ,
173
- UtLinkedListWithNullableCheck ::class ,
174
- UtLinkedList .UtLinkedListIterator ::class ,
175
- UtLinkedList .ReverseIteratorWrapper ::class ,
176
- UtHashSet ::class ,
177
- UtHashSet .UtHashSetIterator ::class ,
178
- UtHashMap ::class ,
179
- UtHashMap .Entry ::class ,
180
- UtHashMap .LinkedEntryIterator ::class ,
181
- UtHashMap .LinkedEntrySet ::class ,
182
- UtHashMap .LinkedHashIterator ::class ,
183
- UtHashMap .LinkedKeyIterator ::class ,
184
- UtHashMap .LinkedKeySet ::class ,
185
- UtHashMap .LinkedValueIterator ::class ,
186
- UtHashMap .LinkedValues ::class ,
187
- RangeModifiableUnlimitedArray ::class ,
188
- AssociativeArray ::class ,
189
- UtGenericStorage ::class ,
190
- UtGenericAssociative ::class ,
191
- PrintStream ::class ,
192
- UtNativeStringWrapper ::class ,
193
- UtString ::class ,
194
- UtStringBuilder ::class ,
195
- UtStringBuffer ::class ,
196
- Stream ::class ,
197
- Arrays ::class ,
198
- Collection ::class ,
199
- UtList ::class ,
200
- UtStream ::class ,
201
- UtStream .UtStreamIterator ::class
117
+ org.utbot.engine.overrides.collections. AbstractCollection ::class ,
118
+ org.utbot.api.mock. UtMock ::class ,
119
+ org.utbot.engine.overrides. UtOverrideMock ::class ,
120
+ org.utbot.engine.overrides. UtLogicMock ::class ,
121
+ org.utbot.engine.overrides. UtArrayMock ::class ,
122
+ org.utbot.engine.overrides. Boolean ::class ,
123
+ org.utbot.engine.overrides. Byte ::class ,
124
+ org.utbot.engine.overrides. Character ::class ,
125
+ org.utbot.engine.overrides. Class ::class ,
126
+ org.utbot.engine.overrides. Integer ::class ,
127
+ org.utbot.engine.overrides. Long ::class ,
128
+ org.utbot.engine.overrides. Short ::class ,
129
+ org.utbot.engine.overrides. System ::class ,
130
+ org.utbot.engine.overrides.collections. UtOptional ::class ,
131
+ org.utbot.engine.overrides.collections. UtOptionalInt ::class ,
132
+ org.utbot.engine.overrides.collections. UtOptionalLong ::class ,
133
+ org.utbot.engine.overrides.collections. UtOptionalDouble ::class ,
134
+ org.utbot.engine.overrides.collections. UtArrayList ::class ,
135
+ org.utbot.engine.overrides.collections. UtArrayList .UtArrayListIterator ::class ,
136
+ org.utbot.engine.overrides.collections. UtLinkedList ::class ,
137
+ org.utbot.engine.overrides.collections. UtLinkedListWithNullableCheck ::class ,
138
+ org.utbot.engine.overrides.collections. UtLinkedList .UtLinkedListIterator ::class ,
139
+ org.utbot.engine.overrides.collections. UtLinkedList .ReverseIteratorWrapper ::class ,
140
+ org.utbot.engine.overrides.collections. UtHashSet ::class ,
141
+ org.utbot.engine.overrides.collections. UtHashSet .UtHashSetIterator ::class ,
142
+ org.utbot.engine.overrides.collections. UtHashMap ::class ,
143
+ org.utbot.engine.overrides.collections. UtHashMap .Entry ::class ,
144
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedEntryIterator ::class ,
145
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedEntrySet ::class ,
146
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedHashIterator ::class ,
147
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedKeyIterator ::class ,
148
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedKeySet ::class ,
149
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedValueIterator ::class ,
150
+ org.utbot.engine.overrides.collections. UtHashMap .LinkedValues ::class ,
151
+ org.utbot.engine.overrides.collections. RangeModifiableUnlimitedArray ::class ,
152
+ org.utbot.engine.overrides.collections. AssociativeArray ::class ,
153
+ org.utbot.engine.overrides.collections. UtGenericStorage ::class ,
154
+ org.utbot.engine.overrides.collections. UtGenericAssociative ::class ,
155
+ org.utbot.engine.overrides. PrintStream ::class ,
156
+ org.utbot.engine. UtNativeStringWrapper ::class ,
157
+ org.utbot.engine.overrides.strings. UtString ::class ,
158
+ org.utbot.engine.overrides.strings. UtStringBuilder ::class ,
159
+ org.utbot.engine.overrides.strings. UtStringBuffer ::class ,
160
+ org.utbot.engine.overrides.stream. Stream ::class ,
161
+ org.utbot.engine.overrides.stream. Arrays ::class ,
162
+ org.utbot.engine.overrides.collections. Collection ::class ,
163
+ org.utbot.engine.overrides.collections. List ::class ,
164
+ org.utbot.engine.overrides.stream. UtStream ::class ,
165
+ org.utbot.engine.overrides.stream. UtStream .UtStreamIterator ::class
202
166
).map { it.java }.toTypedArray()
0 commit comments