powermock: Test failure on JDK11 with PowerMock + JaCoCo offline instrumentation
Steps to reproduce
PowerMock version: JaCoCo version: 0.8.4 Operating system: used this docker image maven:3-jdk-11-slim Tool integration: Maven
Expected behaviour
Complete code coverage equally on different JDK’s
Actual behaviour
Tests breaking on JDK11 and working ok with JDK8
I’ve created a repository to show the problem. I know that the integration between PowerMock and JaCoCo needs to work with offline instrumentation (in some cases) and I’ve created a test project to try it. So I got these results:
-
On branch master uses java11 with online instrumentation. The code coverage on DummyService is 15%
-
On branch java8 uses java8 with offline instrumentation. The code coverage on DummyService is 100%
-
On branch java11 uses java11 with offline instrumentation. The tests are broken with the error bellow:
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.368 s <<< FAILURE! - in br.com.testing.jacocoerror.service.DummyServiceTest
[ERROR] initializationError(br.com.testing.jacocoerror.service.DummyServiceTest) Time elapsed: 0.01 s <<< ERROR!
java.lang.IllegalStateException: Failed to transform class with name br.com.testing.jacocoerror.service.DummyServiceTest. Reason: java.io.IOException: invalid constant type: 17 at 49
Caused by: java.lang.RuntimeException: java.io.IOException: invalid constant type: 17 at 49
Caused by: java.io.IOException: invalid constant type: 17 at 49
I’ve created the same issue inntially on JaCoCo’s repository and as explained there the issue is thrown by PowerMock
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 4
- Comments: 16 (6 by maintainers)
The error comes from Javassist. PowerMock uses javassistVersion = “3.25.0-GA”, the described issue was fixed and released in javassist 3.26.0-GA (https://github.com/jboss-javassist/javassist/issues/270). However it is still not fully compatible with JDK 11, one more issue was found: https://github.com/jboss-javassist/javassist/issues/282.