@@ -1235,7 +1235,14 @@ fun Traverser.toMethodResult(value: Any?, sootType: Type): MethodResult {
1235
1235
1236
1236
val createdElement = if (elementType is RefType ) {
1237
1237
val className = value[it]!! .javaClass.id.name
1238
- createObject(addr, Scene .v().getRefType(className), useConcreteType = true )
1238
+ // Try to take an instance of class we find in Runtime
1239
+ // If it is impossible, take the default `elementType` without a concrete type instead.
1240
+ val (type, useConcreteType) =
1241
+ Scene .v().getRefTypeUnsafe(className)
1242
+ ?.let { type -> type to true }
1243
+ ? : (elementType to false )
1244
+
1245
+ createObject(addr, type, useConcreteType)
1239
1246
} else {
1240
1247
require(elementType is ArrayType )
1241
1248
// We cannot use concrete types since we do not receive
@@ -1262,7 +1269,14 @@ fun Traverser.toMethodResult(value: Any?, sootType: Type): MethodResult {
1262
1269
1263
1270
return asMethodResult {
1264
1271
val addr = UtAddrExpression (mkBVConst(" staticVariable${value.hashCode()} " , UtInt32Sort ))
1265
- createObject(addr, Scene .v().getRefType(refTypeName), useConcreteType = true )
1272
+ // Try to take a type from an object from the Runtime.
1273
+ // If it is impossible, create an instance of a default `sootType` without a concrete type.
1274
+ val (type, useConcreteType) = Scene .v()
1275
+ .getRefTypeUnsafe(refTypeName)
1276
+ ?.let { type -> type to true }
1277
+ ? : (sootType as RefType to false )
1278
+
1279
+ createObject(addr, type, useConcreteType)
1266
1280
}
1267
1281
}
1268
1282
}
0 commit comments