Skip to content
Prev Previous commit
Next Next commit
Fix problem when synthetic methods are used for test generation
  • Loading branch information
Markoutte committed Sep 8, 2023
commit 510099e62b9aa1cb98ae8669e992bfa9bfca8b56
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,12 @@ class BuilderObjectValueProvider(
sootClass.methods.asSequence()
.filter { isAccessible(it, description.description.packageName) }
.filter { (implementors.contains((it.returnType as? RefType)?.sootClass)) }
Comment thread
Markoutte marked this conversation as resolved.
Comment thread
IlyaMuravjov marked this conversation as resolved.
.filter {
// Simple check whether the method is synthetic,
// because Soot has no information about this:
// https://mailman.cs.mcgill.ca/pipermail/soot-list/2012-November/004972.html
!it.name.matches(nameWithDigitsAfterSpecialCharRegex)
Comment thread
Markoutte marked this conversation as resolved.
}
.forEach { method ->
val returnType = method.returnType as RefType
val returnClassId = returnType.classId
Expand Down Expand Up @@ -258,6 +264,8 @@ class BuilderObjectValueProvider(

}

private val nameWithDigitsAfterSpecialCharRegex = """.*\$\d+$""".toRegex()

private fun SootClass.isUseful(): Boolean {
if (!isConcrete) return false
val packageName = packageName
Expand All @@ -269,7 +277,7 @@ private fun SootClass.isUseful(): Boolean {
)
return false
}
val isAnonymousClass = name.matches(""".*\$\d+$""".toRegex())
val isAnonymousClass = name.matches(nameWithDigitsAfterSpecialCharRegex)
Comment thread
Markoutte marked this conversation as resolved.
if (isAnonymousClass) {
return false
}
Expand Down