Avoid ConcurrentModificationException

#KT-26384 Fixed
This commit is contained in:
Mikhael Bogdanov
2019-01-07 16:46:22 +01:00
parent 8ce7112123
commit 6a19e45e27
9 changed files with 146 additions and 3 deletions
@@ -20,6 +20,8 @@ import com.google.common.collect.LinkedListMultimap
import org.jetbrains.kotlin.codegen.optimization.common.isMeaningful
import org.jetbrains.org.objectweb.asm.tree.*
import java.util.*
import kotlin.collections.HashSet
import kotlin.collections.LinkedHashSet
abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) {
val tryBlocksMetaInfo: IntervalMetaInfo<TryCatchBlockNodeInfo> = IntervalMetaInfo(this)
@@ -114,7 +116,7 @@ class IntervalMetaInfo<T : SplittableInterval<T>>(private val processor: Coverin
}
fun splitAndRemoveCurrentIntervals(by: Interval, keepStart: Boolean) {
currentIntervals.map { splitAndRemoveInterval(it, by, keepStart) }
currentIntervals.toList().forEach { splitAndRemoveIntervalFromCurrents(it, by, keepStart) }
}
fun processCurrent(curIns: LabelNode, directOrder: Boolean) {
@@ -140,7 +142,7 @@ class IntervalMetaInfo<T : SplittableInterval<T>>(private val processor: Coverin
return split
}
fun splitAndRemoveInterval(interval: T, by: Interval, keepStart: Boolean): SplitPair<T> {
fun splitAndRemoveIntervalFromCurrents(interval: T, by: Interval, keepStart: Boolean): SplitPair<T> {
val splitPair = split(interval, by, keepStart)
val removed = currentIntervals.remove(splitPair.patchedPart)
assert(removed) { "Wrong interval structure: $splitPair" }
@@ -391,7 +391,7 @@ public class InternalFinallyBlockInliner extends CoveringTryCatchNodeProcessor {
// so we should split original interval by inserted finally one
for (TryCatchBlockNodeInfo block : updatingClusterBlocks) {
//update exception mapping
SplitPair<TryCatchBlockNodeInfo> split = tryBlocksMetaInfo.splitAndRemoveInterval(block, splitBy, false);
SplitPair<TryCatchBlockNodeInfo> split = tryBlocksMetaInfo.splitAndRemoveIntervalFromCurrents(block, splitBy, false);
checkFinally(split.getNewPart());
checkFinally(split.getPatchedPart());
//block patched in split method