From 687924ea2dd15a7d4034cd1e51b953e8597745af Mon Sep 17 00:00:00 2001 From: MchKosticyn Date: Fri, 31 Jan 2025 15:35:57 +0300 Subject: [PATCH 1/2] [fix] fixed `JcLocation` caching --- .../org/jacodb/impl/storage/PersistentByteCodeLocation.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jacodb-core/src/main/kotlin/org/jacodb/impl/storage/PersistentByteCodeLocation.kt b/jacodb-core/src/main/kotlin/org/jacodb/impl/storage/PersistentByteCodeLocation.kt index b1f947bc0..2f5e41332 100644 --- a/jacodb-core/src/main/kotlin/org/jacodb/impl/storage/PersistentByteCodeLocation.kt +++ b/jacodb-core/src/main/kotlin/org/jacodb/impl/storage/PersistentByteCodeLocation.kt @@ -87,10 +87,9 @@ class PersistentByteCodeLocation( } } - override val jcLocation: JcByteCodeLocation? - get() { - return cachedLocation ?: data.toJcLocation() - } + override val jcLocation: JcByteCodeLocation? by lazy(LazyThreadSafetyMode.PUBLICATION) { + cachedLocation ?: data.toJcLocation() + } override val path: String get() = data.path @@ -138,4 +137,3 @@ class PersistentByteCodeLocation( } } } - From d3de6bbe554a9940798b141e6b88b83c30f3184f Mon Sep 17 00:00:00 2001 From: MchKosticyn Date: Fri, 31 Jan 2025 17:01:56 +0300 Subject: [PATCH 2/2] [fix] fixed `Approximations` feature --- .../main/kotlin/org/jacodb/approximation/Approximations.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jacodb-approximations/src/main/kotlin/org/jacodb/approximation/Approximations.kt b/jacodb-approximations/src/main/kotlin/org/jacodb/approximation/Approximations.kt index d661b04a4..eb2280752 100644 --- a/jacodb-approximations/src/main/kotlin/org/jacodb/approximation/Approximations.kt +++ b/jacodb-approximations/src/main/kotlin/org/jacodb/approximation/Approximations.kt @@ -178,13 +178,13 @@ private class ApproximationIndexer( val approximationClassName = classNode.name.className.toApproximationName() // Ensure that each approximation has one and only one - require(originalClassName !in originalToApproximation) { + require(originalToApproximation.getOrDefault(originalClassName, approximationClassName) == approximationClassName) { "An error occurred during approximations indexing: you tried to add `$approximationClassName` " + "as an approximation for `$originalClassName`, but the target class is already " + "associated with approximation `${originalToApproximation[originalClassName]}`. " + "Only bijection between classes is allowed." } - require(approximationClassName !in approximationToOriginal) { + require(approximationToOriginal.getOrDefault(approximationClassName, originalClassName) == originalClassName) { "An error occurred during approximations indexing: you tried to add `$approximationClassName` " + "as an approximation for `$originalClassName`, but this approximation is already used for " + "`${approximationToOriginal[approximationClassName]}`. " +