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

Minions die to RUN_ERRORs in records with annotations #1285

Open
chaosflaws opened this issue Dec 18, 2023 · 1 comment
Open

Minions die to RUN_ERRORs in records with annotations #1285

chaosflaws opened this issue Dec 18, 2023 · 1 comment

Comments

@chaosflaws
Copy link

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.

@hcoles
Copy link
Owner

hcoles commented Dec 21, 2023

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.

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

No branches or pull requests

2 participants