(ClassInstance a, ClassInstance b)
| 171 | } |
| 172 | |
| 173 | public void match(ClassInstance a, ClassInstance b) { |
| 174 | if (a == null) throw new NullPointerException("null class A"); |
| 175 | if (b == null) throw new NullPointerException("null class B"); |
| 176 | if (a.getArrayDimensions() != b.getArrayDimensions()) throw new IllegalArgumentException("the classes don't have the same amount of array dimensions"); |
| 177 | if (a.getMatch() == b) return; |
| 178 | |
| 179 | LOGGER.debug("Matching class {} -> {}{}", a, b, (a.hasMappedName() ? " ("+a.getName(NameType.MAPPED_PLAIN)+")" : "")); |
| 180 | |
| 181 | if (a.getMatch() != null) { |
| 182 | a.getMatch().setMatch(null); |
| 183 | unmatchMembers(a); |
| 184 | } |
| 185 | |
| 186 | if (b.getMatch() != null) { |
| 187 | b.getMatch().setMatch(null); |
| 188 | unmatchMembers(b); |
| 189 | } |
| 190 | |
| 191 | a.setMatch(b); |
| 192 | b.setMatch(a); |
| 193 | |
| 194 | // match array classes |
| 195 | |
| 196 | if (a.isArray()) { |
| 197 | ClassInstance elemA = a.getElementClass(); |
| 198 | |
| 199 | if (!elemA.hasMatch()) match(elemA, b.getElementClass()); |
| 200 | } else { |
| 201 | for (ClassInstance arrayA : a.getArrays()) { |
| 202 | int dims = arrayA.getArrayDimensions(); |
| 203 | |
| 204 | for (ClassInstance arrayB : b.getArrays()) { |
| 205 | if (arrayB.hasMatch() || arrayB.getArrayDimensions() != dims) continue; |
| 206 | |
| 207 | assert arrayA.getElementClass() == a && arrayB.getElementClass() == b; |
| 208 | |
| 209 | match(arrayA, arrayB); |
| 210 | break; |
| 211 | } |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | // match methods that are not obfuscated or matched via parents/children |
| 216 | |
| 217 | for (MethodInstance src : a.getMethods()) { |
| 218 | if (!src.isNameObfuscated()) { |
| 219 | MethodInstance dst = b.getMethod(src.getId()); |
| 220 | |
| 221 | if ((dst != null || (dst = b.getMethod(src.getName(), null)) != null) && !dst.isNameObfuscated()) { // full match or name match with no alternatives |
| 222 | match(src, dst); |
| 223 | continue; |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | MethodInstance matchedDst = src.getHierarchyMatch(); |
| 228 | if (matchedDst == null) continue; |
| 229 | |
| 230 | Set<MethodInstance> dstHierarchyMembers = matchedDst.getAllHierarchyMembers(); |
no test coverage detected