Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Initiate concrete execution if a wrapper method is missing
If a JVM class is overridden but a method is missing from the wrapper,
the engine will discard the path and fall back to concrete execution
instead of analysing the real JVM code graph.

This approach fixes the problem with methods that have been introduced
in newer JDKs. Now wrappers are mostly limited to Java 1.8 interfaces
and fail to analyze methods like `String::isBlank` or `String::lines`
when the code runs under JDK 11. Building graphs from the real JDK code
fails because the wrapper does not have private fields that the original
code uses.

TODO: to allow symbolic analysis of the code, missing methods should be
actually implemented in corresponding wrappers.
  • Loading branch information
dtim committed Jul 4, 2022
commit f535810193d0e3dd6e495ad6153decc965df01aa
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import org.utbot.engine.overrides.collections.UtHashSet
import org.utbot.engine.overrides.collections.UtLinkedList
import org.utbot.engine.pc.UtAddrExpression
import org.utbot.engine.pc.UtExpression
import org.utbot.engine.pc.UtFalse
import org.utbot.engine.pc.select
import org.utbot.engine.symbolic.asHardConstraint
import org.utbot.engine.z3.intValue
Expand Down Expand Up @@ -84,10 +85,15 @@ abstract class BaseOverriddenWrapper(protected val overriddenClassName: String)

val overriddenMethod = overriddenClass.findMethodOrNull(method.subSignature)

val jimpleBody = overriddenMethod?.jimpleBody() ?: method.jimpleBody()
val graphResult = GraphResult(jimpleBody.graph())

return listOf(graphResult)
if (overriddenMethod == null) {
// No overridden method has been found, switch to concrete execution
pathLogger.warn("Method ${overriddenClass.name}::${method.subSignature} not found, executing concretely")
return emptyList()
} else {
val jimpleBody = overriddenMethod.jimpleBody()
val graphResult = GraphResult(jimpleBody.graph())
return listOf(graphResult)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3079,6 +3079,11 @@ class UtBotSymbolicEngine(

instanceAsWrapperOrNull?.run {
val results = invoke(instance as ObjectValue, invocation.method, invocation.parameters)
if (results.isEmpty()) {
// Drop the branch and switch to concrete execution
statesForConcreteExecution += environment.state
queuedSymbolicStateUpdates += UtFalse.asHardConstraint()
}
return OverrideResult(success = true, results)
}

Expand Down