Description
Pitest creates mutations for null assignments to final variables, but these mutations cannot be properly tested because removing the assignment would cause a compilation failure (uninitialized final variable).
Example Code
public class Example {
private final List items;
public Example(Collection input) {
if (input == null) {
this.items = null; // ← Pitest mutates this
} else {
this.items = new ArrayList<>(input);
}
}
}
Current Behavior
Pitest creates mutations like:
- Removing the assignment:
// this.items = null;
However, if the assignment is removed, the code doesn't compile because items is final and must be initialized in all code paths.
Problem
Since the mutated code still compiles (Pitest works on bytecode level), tests cannot distinguish between:
- Original:
this.items = null (explicit null assignment)
- Mutated: No assignment (implicit null/uninitialized in source, but valid bytecode)
This creates unkillable mutations for final variables.
Expected Behavior
Pitest should either:
- Skip mutations for null assignments to final variables
- Detect that the mutation would cause compilation failure if written as source code
- Provide a configuration option to exclude these mutations
Description
Pitest creates mutations for
nullassignments tofinalvariables, but these mutations cannot be properly tested because removing the assignment would cause a compilation failure (uninitialized final variable).Example Code
Current Behavior
Pitest creates mutations like:
// this.items = null;However, if the assignment is removed, the code doesn't compile because
itemsisfinaland must be initialized in all code paths.Problem
Since the mutated code still compiles (Pitest works on bytecode level), tests cannot distinguish between:
this.items = null(explicit null assignment)This creates unkillable mutations for final variables.
Expected Behavior
Pitest should either: