Pitest not filtering try-with-resources correctly in Java 11
See original GitHub issueSummary
Pitest is trying to mutate bytecode used for closing resources when using the try-with-resources in Java 11
Expected: No mutations on the generated parts of the bytecode, this behaviour works correctly in Java 8 Actual: Mutations happening on the generated parts in the bytecode used for closing the resources that are used in the try block
Steps to reproduce
- Check out the example project
- Run
mvn clean test pitest:mutationCoverage
- Look at the pitest report, it shows mutations on the try block
Other info
Probably this is related to #689
Tested with OpenJDK
Java 11
openjdk version "11.0.7" 2020-04-14
OpenJDK Runtime Environment (build 11.0.7+10-post-Ubuntu-2ubuntu218.04)
OpenJDK 64-Bit Server VM (build 11.0.7+10-post-Ubuntu-2ubuntu218.04, mixed mode, sharing)
Java 8
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-8u252-b09-1~18.04-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
I also checked out the pitest repository locally. When I create a test in TryWithResourcesFilterTest
with the Java 11 bytecode from my local JDK I don’t see any mutation being filtered. When I run the same test on a Java 8 class file it does filter out mutations
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:5 (2 by maintainers)
Top Results From Across the Web
try with resources block generates unkillable mutants #255
If you use a try-with-resources block in your Java code and run PITest on it, ... Somehow it seems that it is currently...
Read more >FAQ - PIT Mutation Testing
Make sure that your code and tests are properly referenced on the classpath, and check that the filters are not excluding your code....
Read more >JaCoCo and PITest - No mutations found. This probably ...
JaCoCo and PITest - No mutations found. This probably means there is an issue with either the supplied classpath or filters. 2283 views....
Read more >Pit Mutation Test: tests found, no minions possible
I use the PIT Mutation Test for a huge java programm (over 450.000 LOC). ... [INFO] Found plugin : Try with resources filter...
Read more >The try-with-resources Statement - Exceptions
This Java tutorial describes exceptions, basic input/output, concurrency, regular expressions, and the platform environment.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has gone a little easier than I’d exepected, so I’ll push a release out later today.
New filtering catches the issues in @johnsterken 's example, plus some sample real world projects. I expect there will be further issues with more complex examples, but current code seems to give 90% of the benefit.
Sorry for the delay fixing this folks, it is very annoying. Should have something out early next week.