Skip to content

Commit e8d99a8

Browse files
committed
Fixed review issues
1 parent 999536b commit e8d99a8

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ import org.utbot.engine.symbolic.asUpdate
8888
import org.utbot.engine.simplificators.MemoryUpdateSimplificator
8989
import org.utbot.engine.simplificators.simplifySymbolicStateUpdate
9090
import org.utbot.engine.simplificators.simplifySymbolicValue
91+
import org.utbot.engine.types.CLASS_REF_SOOT_CLASS
9192
import org.utbot.engine.types.CLASS_REF_TYPE
9293
import org.utbot.engine.types.ENUM_ORDINAL
9394
import org.utbot.engine.types.EQUALS_SIGNATURE
@@ -423,8 +424,11 @@ class Traverser(
423424
private fun TraversalContext.pushInitGraphAfterNewInstanceReflectionCall(stmt: JAssignStmt): Boolean {
424425
// Check whether the previous stmt was a `newInstance` invocation
425426
val lastStmt = environment.state.path.lastOrNull() as? JAssignStmt ?: return false
426-
val lastStmtRight = lastStmt.rightOp as? JVirtualInvokeExpr ?: return false
427-
val lastMethodInvocation = lastStmtRight.retrieveMethod()
427+
if (!lastStmt.containsInvokeExpr()) {
428+
return false
429+
}
430+
431+
val lastMethodInvocation = lastStmt.invokeExpr.method
428432
if (lastMethodInvocation.subSignature != NEW_INSTANCE_SIGNATURE) {
429433
return false
430434
}
@@ -2963,8 +2967,9 @@ class Traverser(
29632967
}
29642968
}
29652969

2966-
// Return an unbounded symbolic variable for any `forName` overloading
2967-
if (instance == null && invocation.method.name == "forName") {
2970+
// Return an unbounded symbolic variable for any overloading of method `forName` of class `java.lang.Class`
2971+
// NOTE: we cannot match by a subsignature here since `forName` method has a few overloadings
2972+
if (instance == null && invocation.method.declaringClass == CLASS_REF_SOOT_CLASS && invocation.method.name == "forName") {
29682973
val forNameResult = unboundedVariable(name = "classForName", invocation.method)
29692974

29702975
return OverrideResult(success = true, forNameResult)

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import soot.NullType
3939
import soot.PrimType
4040
import soot.RefType
4141
import soot.Scene
42+
import soot.SootClass
4243
import soot.SootField
4344
import soot.Type
4445
import soot.VoidType
@@ -344,7 +345,8 @@ internal val CLASS_REF_NUM_DIMENSIONS_DESCRIPTOR: MemoryChunkDescriptor
344345
IntType.v()
345346
)
346347

347-
internal val CLASS_REF_SOOT_CLASS = Scene.v().getSootClass(CLASS_REF_CLASSNAME)
348+
internal val CLASS_REF_SOOT_CLASS: SootClass
349+
get() = Scene.v().getSootClass(CLASS_REF_CLASSNAME)
348350

349351
internal val OBJECT_TYPE: RefType
350352
get() = Scene.v().getSootClass(Object::class.java.canonicalName).type

0 commit comments

Comments
 (0)