Skip to content

Commit c5bb35d

Browse files
committed
Remove our classes from the hierarchy
1 parent a2ca8ae commit c5bb35d

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

utbot-framework/src/main/kotlin/org/utbot/engine/TypeResolver.kt

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,16 +120,13 @@ class TypeResolver(private val typeRegistry: TypeRegistry, private val hierarchy
120120
return false
121121
}
122122

123-
if (baseType.sootClass.packageName.startsWith("org.utbot")) {
124-
return true
125-
}
123+
val baseSootClass = baseType.sootClass
126124

127-
if (baseType.sootClass.packageName.startsWith("soot")) {
125+
// We don't want to have our overridden class as a part of a regular TypeStorage instance
126+
if (baseSootClass.isOverridden) {
128127
return true
129128
}
130129

131-
val baseSootClass = baseType.sootClass
132-
133130
if (numDimensions == 0 && baseSootClass.isInappropriate) {
134131
// interface, abstract class, or local, or mock could not be constructed
135132
return true

utbot-framework/src/main/kotlin/org/utbot/framework/util/SootUtils.kt

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,31 @@ private fun initSoot(buildDirs: List<Path>, classpath: String?, jdkInfo: JdkInfo
8989
Scene.v().loadNecessaryClasses()
9090
PackManager.v().runPacks()
9191
// we need this to create hierarchy of classes
92-
Scene.v().classes.forEach {
93-
if (it.resolvingLevel() < SootClass.HIERARCHY)
92+
Scene.v().classes.toList().forEach {
93+
val isUtBotPackage = it.packageName.startsWith(UTBOT_PACKAGE_PREFIX)
94+
95+
// remove our own classes from the soot scene
96+
if (isUtBotPackage) {
97+
val isOverriddenPackage = it.packageName.startsWith(UTBOT_OVERRIDDEN_PACKAGE_PREFIX)
98+
val isExamplesPackage = it.packageName.startsWith(UTBOT_EXAMPLES_PACKAGE_PREFIX)
99+
val isApiPackage = it.packageName.startsWith(UTBOT_API_PACKAGE_PREFIX)
100+
101+
// remove if it is not a part of the examples (CUT), not a part of our API and not an override
102+
if (!isOverriddenPackage && !isExamplesPackage && !isApiPackage) {
103+
Scene.v().removeClass(it)
104+
return@forEach
105+
}
106+
}
107+
108+
// remove soot's classes from the scene, because we don't wont to analyze them
109+
if (it.packageName.startsWith(SOOT_PACKAGE_PREFIX)) {
110+
Scene.v().removeClass(it)
111+
return@forEach
112+
}
113+
114+
if (it.resolvingLevel() < SootClass.HIERARCHY) {
94115
it.setResolvingLevel(SootClass.HIERARCHY)
116+
}
95117
}
96118
}
97119

@@ -171,4 +193,10 @@ private val classesToLoad = arrayOf(
171193
org.utbot.engine.overrides.stream.IntStream::class,
172194
org.utbot.engine.overrides.stream.LongStream::class,
173195
org.utbot.engine.overrides.stream.DoubleStream::class,
174-
).map { it.java }.toTypedArray()
196+
).map { it.java }.toTypedArray()
197+
198+
private const val UTBOT_PACKAGE_PREFIX = "org.utbot"
199+
private const val UTBOT_EXAMPLES_PACKAGE_PREFIX = "$UTBOT_PACKAGE_PREFIX.examples"
200+
private const val UTBOT_API_PACKAGE_PREFIX = "$UTBOT_PACKAGE_PREFIX.api"
201+
private const val UTBOT_OVERRIDDEN_PACKAGE_PREFIX = "$UTBOT_PACKAGE_PREFIX.engine.overrides"
202+
private const val SOOT_PACKAGE_PREFIX = "soot."

0 commit comments

Comments
 (0)