Skip to content

Commit deeaae6

Browse files
authored
Fixes (#299)
* [fix] fixed `JcLocation` caching * [fix] fixed `Approximations` feature
1 parent 3904c0e commit deeaae6

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

jacodb-approximations/src/main/kotlin/org/jacodb/approximation/Approximations.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,13 +178,13 @@ private class ApproximationIndexer(
178178
val approximationClassName = classNode.name.className.toApproximationName()
179179

180180
// Ensure that each approximation has one and only one
181-
require(originalClassName !in originalToApproximation) {
181+
require(originalToApproximation.getOrDefault(originalClassName, approximationClassName) == approximationClassName) {
182182
"An error occurred during approximations indexing: you tried to add `$approximationClassName` " +
183183
"as an approximation for `$originalClassName`, but the target class is already " +
184184
"associated with approximation `${originalToApproximation[originalClassName]}`. " +
185185
"Only bijection between classes is allowed."
186186
}
187-
require(approximationClassName !in approximationToOriginal) {
187+
require(approximationToOriginal.getOrDefault(approximationClassName, originalClassName) == originalClassName) {
188188
"An error occurred during approximations indexing: you tried to add `$approximationClassName` " +
189189
"as an approximation for `$originalClassName`, but this approximation is already used for " +
190190
"`${approximationToOriginal[approximationClassName]}`. " +

jacodb-core/src/main/kotlin/org/jacodb/impl/storage/PersistentByteCodeLocation.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,9 @@ class PersistentByteCodeLocation(
8787
}
8888
}
8989

90-
override val jcLocation: JcByteCodeLocation?
91-
get() {
92-
return cachedLocation ?: data.toJcLocation()
93-
}
90+
override val jcLocation: JcByteCodeLocation? by lazy(LazyThreadSafetyMode.PUBLICATION) {
91+
cachedLocation ?: data.toJcLocation()
92+
}
9493

9594
override val path: String
9695
get() = data.path
@@ -138,4 +137,3 @@ class PersistentByteCodeLocation(
138137
}
139138
}
140139
}
141-

0 commit comments

Comments
 (0)