pitest
pitest copied to clipboard
Minions die to `RUN_ERROR`s in records with annotations
The code with the issue can be found at: https://github.com/chaosflaws/pitest-record-annotations-bug, should be reproducible with mvn verify
.
In this snippet:
public record SafeRange(@Nullable LocalDate start,
@Nullable LocalDate end)
implements DateRange {
public SafeFiniteRange toFinite() {
if (start == null)
throw new IllegalStateException();
if (end == null)
throw new IllegalStateException();
return new SafeFiniteRange(start, end);
}
}
Pitest mutations die with the following stack trace:
stdout : java.lang.UnsupportedOperationException: class redefinition failed: attempted to change the class NestHost, NestMembers, Record, or PermittedSubclasses attribute
stdout : at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
stdout : at java.instrument/sun.instrument.InstrumentationImpl.redefineClasses(InstrumentationImpl.java:195)
stdout : at org.pitest.boot.HotSwapAgent.hotSwap(HotSwapAgent.java:46)
stdout : at org.pitest.mutationtest.execute.CatchNewClassLoadersTransformer.setMutant(CatchNewClassLoadersTransformer.java:44)
stdout : at org.pitest.mutationtest.execute.HotSwap.insertClass(HotSwap.java:18)
stdout : at org.pitest.mutationtest.execute.MutationTestWorker.handleCoveredMutation(MutationTestWorker.java:152)
stdout : at org.pitest.mutationtest.execute.MutationTestWorker.handleMutation(MutationTestWorker.java:133)
stdout : at org.pitest.mutationtest.execute.MutationTestWorker.processMutation(MutationTestWorker.java:115)
stdout : at org.pitest.mutationtest.execute.MutationTestWorker.run(MutationTestWorker.java:85)
stdout : at org.pitest.mutationtest.execute.MutationTestMinion.run(MutationTestMinion.java:97)
stdout : at org.pitest.mutationtest.execute.MutationTestMinion.main(MutationTestMinion.java:153)
Removing the annotations makes the error go away.
Thanks for the report and reproduction example. My best guess here is that ASM is reordering an attribute behind the scenes, but this wouldn't explain why the first mutant inserts succesfully.