Skip to content

Bug: False positive for ChainingConstructorIgnoresParameter for array concatenation passing #5472

@Fox2Code

Description

@Fox2Code

The following pattern:

public class MyClass {
        final String[] targets;

	MyClass(String target) {
		this.targets = new String[]{target};
	}

	MyClass(String[] targets) {
		this.targets = targets;
	}

	MyClass(String target, String... targets) {
		String[] newTargets = new String[targets.length + 1];
		newTargets[0] = target;
		System.arraycopy(targets, 0, newTargets, 1, targets.length);
		this(newTargets);
	}
}

Cause a ChainingConstructorIgnoresParameter false-positive!

Found out while doing stuff on my project, original code is there:
https://github.com/Fox2Code/Hypertale/blob/master/patcher/src/main/java/com/fox2code/hypertale/patcher/patches/HypertalePatch.java

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions