Skip to content

Commit d2b456e

Browse files
committed
Fix JRE-dependent IDs causing tests to fail
1 parent e136373 commit d2b456e

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/test/kotlin/me/cfpq/pointsto/miner/TestGraphUtils.kt

+9-5
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,32 @@ fun readGraph(paths: GraphPaths): DeserializedGraph {
4949
val (source, target, label) = parts
5050
val field = parts.getOrNull(3)
5151
TestEdge(
52-
vertexMappings.getValue(source.toInt()),
53-
vertexMappings.getValue(target.toInt()),
52+
vertexMappings.getValue(source.toInt()).withoutJacoDbIds(),
53+
vertexMappings.getValue(target.toInt()).withoutJacoDbIds(),
5454
label,
55-
field?.let { fieldMappings.getValue(it.toInt()) }
55+
field?.let { fieldMappings.getValue(it.toInt()) }?.withoutJacoDbIds()
5656
)
5757
}.toSet()
5858
},
5959
vertexToType = paths.typesURL.openStream().bufferedReader().useLines { lines ->
6060
lines.associate { line ->
6161
val (vertex, type) = line.splitWords()
62-
vertexMappings.getValue(vertex.toInt()) to typeMappings.getValue(type.toInt())
62+
vertexMappings.getValue(vertex.toInt()).withoutJacoDbIds() to typeMappings.getValue(type.toInt())
6363
}
6464
},
6565
vertexToSupTypes = paths.typesURL.openStream().bufferedReader().useLines { lines ->
6666
lines.map { line ->
6767
val (vertex, type) = line.splitWords()
68-
vertexMappings.getValue(vertex.toInt()) to typeMappings.getValue(type.toInt())
68+
vertexMappings.getValue(vertex.toInt()).withoutJacoDbIds() to typeMappings.getValue(type.toInt())
6969
}
7070
.groupBy(keySelector = { it.first }, valueTransform = { it.second })
7171
.mapValues { it.value.toSet() }
7272
}
7373
)
7474
}
7575

76+
// JacoDB generates JRE-dependent ID for every method and field (e.g. `(id:7)java.lang.Object#<init>()`)
77+
private fun String.withoutJacoDbIds(): String =
78+
replace("""\(id:\d+\)""".toRegex(), "(id:jre-dependent)")
79+
7680
private fun String.splitWords() = split("\\s+".toRegex())

0 commit comments

Comments
 (0)