From 49a82c83887839d126d195c3d34fc6801f3cbe32 Mon Sep 17 00:00:00 2001 From: Skylot Date: Sat, 29 Feb 2020 19:22:18 +0000 Subject: [PATCH] fix: method info cache error (#868) --- .../src/main/java/jadx/core/dex/info/InfoStorage.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jadx-core/src/main/java/jadx/core/dex/info/InfoStorage.java b/jadx-core/src/main/java/jadx/core/dex/info/InfoStorage.java index 4996d18f..b0a79a5a 100644 --- a/jadx-core/src/main/java/jadx/core/dex/info/InfoStorage.java +++ b/jadx-core/src/main/java/jadx/core/dex/info/InfoStorage.java @@ -26,20 +26,22 @@ public class InfoStorage { } } - private int generateMethodLookupId(DexNode dex, int mthId) { + private static int generateMethodLookupId(DexNode dex, int mthId) { return dex.getDexId() << 16 | mthId; } public MethodInfo getMethod(DexNode dex, int mtdId) { - return methods.get(generateMethodLookupId(dex, mtdId)); + synchronized (methods) { + return methods.get(generateMethodLookupId(dex, mtdId)); + } } public MethodInfo putMethod(DexNode dex, int mthId, MethodInfo methodInfo) { synchronized (methods) { MethodInfo uniqueMethodInfo = putMethod(methodInfo); MethodInfo prev = methods.put(generateMethodLookupId(dex, mthId), uniqueMethodInfo); - if (prev != null) { - throw new JadxRuntimeException("Method info already added: " + methodInfo); + if (prev != null && prev != uniqueMethodInfo) { + throw new JadxRuntimeException("Method lookup id collision: " + methodInfo + ", " + prev + ", " + uniqueMethodInfo); } return uniqueMethodInfo; } -- GitLab