diff options
author | Shigeru Chiba <chibash@users.noreply.github.com> | 2021-04-26 02:35:45 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 02:35:45 +0900 |
commit | 5fade7ee6e4a75f0100175badfc95cfb36d685da (patch) | |
tree | e10a0508c2515574adda80df767208598a6d97d8 /src/main/javassist | |
parent | f0c343a4b53b366f798620a3527f0958e929396f (diff) | |
parent | a30320948978d8d9610c10fce996ee50ff57d553 (diff) | |
download | javassist-5fade7ee6e4a75f0100175badfc95cfb36d685da.tar.gz javassist-5fade7ee6e4a75f0100175badfc95cfb36d685da.zip |
Merge pull request #306 from nschaefe/master
fix issue 305: CodeConverter.replaceArrayAccess leads to java.util.ConcurrentModificationException
Diffstat (limited to 'src/main/javassist')
-rw-r--r-- | src/main/javassist/bytecode/analysis/Type.java | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main/javassist/bytecode/analysis/Type.java b/src/main/javassist/bytecode/analysis/Type.java index db02df35..33dc81f3 100644 --- a/src/main/javassist/bytecode/analysis/Type.java +++ b/src/main/javassist/bytecode/analysis/Type.java @@ -15,9 +15,7 @@ */ package javassist.bytecode.analysis; -import java.util.HashMap; -import java.util.IdentityHashMap; -import java.util.Map; +import java.util.*; import javassist.ClassPool; import javassist.CtClass; @@ -496,24 +494,26 @@ public class Type { if (typeMap == null||typeMap.isEmpty()) alterMap.clear(); - for (String name:alterMap.keySet()) + Iterator<String> it = alterMap.keySet().iterator(); + while (it.hasNext()) { + String name = it.next(); if (!typeMap.containsKey(name)) - alterMap.remove(name); + it.remove(); + } // Reduce to subinterfaces // This does not need to be recursive since we make a copy, // and that copy contains all super types for the whole hierarchy - for (CtClass intf:alterMap.values()) { - CtClass[] interfaces; + Collection<CtClass> interfaces = new ArrayList<>(); + for (CtClass intf : alterMap.values()) { try { - interfaces = intf.getInterfaces(); + interfaces.addAll(Arrays.asList(intf.getInterfaces())); } catch (NotFoundException e) { throw new RuntimeException(e); } - - for (CtClass c:interfaces) - alterMap.remove(c.getName()); } + for (CtClass c : interfaces) + alterMap.remove(c.getName()); return alterMap; } |