-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
[feature] Use Kotlin's internal null checks to get variable names #1207
Comments
Not the best idea to trust metadata blindly. It can easily be modified by code protectors. Same goes for dex debug metadata. All those items should be imported as opt-ins only imo (default being no import). That's how JEB does it afair. |
This is a genius idea; and in 98%+ of the cases should be 100% correct. Such an easy and simple win! |
Implemented 🎉 Additional implementation details:
Any suggestions and samples are welcome 👍 |
Sorry if this is not the right place for such questions. I have been trying this feature but I see that in some apps the Intrinsics class is located somewhere else. May I ask if there are any existing method that can allow me to do so? |
Edited: |
When Kotlin code is compiled, a bunch of null checks will be added to the code. Some of these may include the variable names from the original source code to generate more helpful error messages.
Here is an example snippet from an APK I recently decompiled using JADX GUI:
Notice how it uses these internal methods to check if the parameters and variables are null. The first parameter is the actual value, while the second parameter is a string representation of it. The
Intrinsics
module is imported fromkotlin.jvm.internal.Intrinsics
and the source code for that can be found here.These are the list of methods I found to be useful for decompilation:
checkExpressionValueIsNotNull(Object value, String expression)
checkNotNullExpressionValue(Object value, String expression)
checkReturnedValueIsNotNull(Object value, String className, String methodName)
checkFieldIsNotNull(Object value, String className, String fieldName)
checkParameterIsNotNull(Object value, String paramName)
checkNotNullParameter(Object value, String paramName)
My suggestion is that during decompilation, JADX should check to see if these methods are being called and if they are, change the variable, parameter, method and class names according to the strings provided in the second (and third) parameter.
The text was updated successfully, but these errors were encountered: