skylot / jadx

Dex to Java decompiler
Apache License 2.0
41.81k stars 4.88k forks source link

[gui] Find usage of public field of interface in all classes #1801

Closed zzzzfeng closed 1 year ago

zzzzfeng commented 1 year ago

When I use find Usage(x) on a public static field of a interface class, there is no result. But I do found the field used by other class, and can be redirected to the field by double-click

skylot commented 1 year ago

@zzzzfeng please share a sample and class/field name, otherwise I can't reproduce and fix this issue.

zzzzfeng commented 1 year ago

Sample jar: zframework.z.jar.zip Just remove the zip extension

When I set the language to Chinese, it happens. But not for English image

the field DESCRIPTOR has many usage in ohos.bundle.BundleManager

skylot commented 1 year ago

Oh, I see! This field actually not used in bytecode because it is replaced by compiler to its string value. But during decompilation jadx tries to replace string back to field usage. So as result if you open only IBundleManager class you will see 0 usages, but after also opening BundleManager new use places will be added from that class, so next time usage list will not be empty. As workaround for now, you can disable Replace constants option in preferences, so strings will be not replaced by fields. Another workaround is to force decompilation of all classes by searching some not used string to see complete results (maybe I should add Decompile All button :slightly_smiling_face:)

skylot commented 1 year ago

@zzzzfeng I commit a fix. It is not the best solution, but it should resolve the issue.