Skip to content

Commit

Permalink
fix: method info cache error (#868)
Browse files Browse the repository at this point in the history
  • Loading branch information
skylot committed Feb 29, 2020
1 parent 26bad4a commit 49a82c8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions jadx-core/src/main/java/jadx/core/dex/info/InfoStorage.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,22 @@ public ClassInfo putCls(ClassInfo cls) {
}
}

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;
}
Expand Down

0 comments on commit 49a82c8

Please sign in to comment.