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

fix: inline anonymous class wrongly handles field as Classname.this #2367

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

ewt45
Copy link
Contributor

@ewt45 ewt45 commented Dec 12, 2024

If option "inline anonymous class" is checked, sometimes the field of the anonymous class is wrongly recoginized as the instance of its parent class, which actually is instance of a random class. This leads to the field being added CLASS_INSTANCE type FieldReplaceAttr and displayed as FieldClassName.this rather than its normal name.

example dex
decompiled code: notice that another is displayed as AnotherClass.this

public class Parent {
    public static Parent test(Class<?> cls) {
        final AnotherClass another = new AnotherClass();
        return new Parent() { // from class: jadxtest.Parent.1
            @Override // jadxtest.Parent
            public String func() {
                return AnotherClass.this.toString();
            }
        };
    }

    public String func() {
        return "";
    }
}

this pr extracts Objects.equals(parentClass, fieldsCls.getClassInfo()), and only add CLASS_INSTANCE replace attr if it is true.

Copy link
Owner

@skylot skylot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thank you 👍

@skylot skylot merged commit 17695ba into skylot:master Dec 12, 2024
4 checks passed
@ewt45 ewt45 deleted the fix-class_this branch December 13, 2024 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants