Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistencies in test execution when flushing type caches #75

Merged
merged 2 commits into from
Jul 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions OPAL/br/src/main/scala/org/opalj/br/Type.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1125,13 +1125,17 @@ object ObjectType {
updateObjectTypes()

try {
// Remove all non-predefined OTs from the cache
Range(highestPredefinedTypeId + 1, objectTypes.length)
.foreach(i => cache.remove(objectTypes(i).fqn))
// Clear the entire cache
cache.clear()

// Truncate the ObjectType cache array to lose all not-predefined ObjectTypes
objectTypes = JArrays.copyOf(objectTypes, highestPredefinedTypeId + 1)

// Refill the cache using the objectTypes array
objectTypes.foreach { ot =>
cache.put(ot.fqn, new WeakReference[ObjectType](ot))
}

// Reset ID counter to highest id in the cache
nextId.set(highestPredefinedTypeId + 1)
} finally {
Expand Down Expand Up @@ -1615,13 +1619,20 @@ object ArrayType {
// we might delete the predefined types
updateArrayTypes()

// Remove all non-predefined ATs from the cache
Range(-lowestPredefinedTypeId + 1, arrayTypes.length)
.foreach(i => cache.remove(arrayTypes(i).componentType))
// Clear the entire cache
cache.clear()

// Reset array to only contain predefined ATs
arrayTypes = JArrays.copyOf(arrayTypes, -lowestPredefinedTypeId + 1)

// Refill the cache using the arrayTypes array
arrayTypes.foreach { at =>
// arrayTypes(0) is gonna be null, so we need this guard
if (at != null) {
cache.put(at.componentType, new WeakReference[ArrayType](at))
}
}

// Reset id counter
nextId.set(lowestPredefinedTypeId - 1)

Expand Down