Skip to content

fix: compare field initializer values across constructors - #2956

Open
oriori1703 wants to merge 1 commit into
skylot:masterfrom
oriori1703:fix/compare-constructor-initializers
Open

oriori1703 wants to merge 1 commit into
skylot:masterfrom
oriori1703:fix/compare-constructor-initializers

Conversation

@oriori1703

@oriori1703 oriori1703 commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

JADX can incorrectly replace different constructor assignments with one shared field initializer, changing the behavior of the decompiled code. In this example, the second constructor should set value to 2, but the broken output gives both constructors 1.

Broken output

class Example {
    final int value = 1;

    Example() {}

    Example(int ignored) {}
}

Fixed output

class Example {
    final int value;

    Example() {
        this.value = 1;
    }

    Example(int ignored) {
        this.value = 2;
    }
}

Testing

Field-initialization tests, Checkstyle, and Spotless pass. The full clean build dist was not run.

@oriori1703
oriori1703 marked this pull request as draft September 15, 2026 09:11
@oriori1703
oriori1703 marked this pull request as ready for review September 15, 2026 09:58
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.

1 participant