Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing constant issue[core] #1277

Open
redmi111 opened this issue Nov 16, 2021 · 6 comments
Open

Replacing constant issue[core] #1277

redmi111 opened this issue Nov 16, 2021 · 6 comments
Labels
bug Core Issues in jadx-core module

Comments

@redmi111
Copy link

I noticed this bug in Replace constants option. When the replace constant is unchecked the values on constant fields are properly decoded (but lose R classes info as we're not replacing constants) and when I check that option R classes constants are properly decoded but the constants in the fields are lost (not decoded I mean not available).

Example:
image

In the above pic Take a look at the CHARSET field and it actually with the Replace constant checked but since there is a constant value available in bytecode it uses STRING_CHARSET_NAME but when there is no such available in bytecode the field declaration was empty.

image

Above one is with Replace constant unchecked.

@redmi111 redmi111 added bug Core Issues in jadx-core module labels Nov 16, 2021
@skylot
Copy link
Owner

skylot commented Nov 16, 2021

@redmi111 do you want an option to enable only R constant replacement?

@redmi111
Copy link
Author

That might actually avoid this issue but not sure if it also will replace other constants properly.

@skylot
Copy link
Owner

skylot commented Nov 16, 2021

will replace other constants properly

I don't see any improper replace in your example. Can you point me which parts are incorrect?
I agree that sometimes constant replaced with one from another context, but constant value is always correct. At least I don't see incorrect constants yet.

@redmi111
Copy link
Author

redmi111 commented Nov 16, 2021

There are no incorrect replacements but missing replacements for a few fields where there is no value from any context.

For example take a field like below,

private static String TAG = "TAG"; -> When replace constant unchecked
It becomes like,

private static String TAG; -> When replace constants was enabled. Here it is missing the value for that field.

Actually, this doesn't happen every time (as long as the value was found somewhere in the code, it can be in a different class or in the same class different field) When there is no value found for it then it skips that.

@MrIkso
Copy link
Contributor

MrIkso commented Nov 16, 2021

@redmi111, look at the byte code and be surprised that if the final field is static, then a reference to it is not used, but the value is taken immediately. I don't see critical bug here.

@skylot
Copy link
Owner

skylot commented Nov 21, 2021

@redmi111 I commit a fix for a missing field init values. This issue depends on processing order and occur if several thread used for decompilation. Not sure if it was your issue, so please check latest unstable build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Core Issues in jadx-core module
Projects
None yet
Development

No branches or pull requests

3 participants