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]}`. " + 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( } } } -