1
votes

First of all I want to mention that I read a lot about this problem and I didn't find any solution.

I have some unit test class, where I use mockstatic method for another class. Then when I run tests it throws "Inconsistent stackmap frames at branch..." error.

I tried all known for me ways e.g. -XX:-UseSplitVerifier or -noverify params added to maven surefire plugin, but none of them works fine. I have all the time the same state.

I tried to change version of PowerMock - older and newest - nothing changed.

I use library: PowerMockito 1.62 (using Javassist 3.19.0-GA version) Java 1.8 Maven 3.2.5

Please let me know, is there any working solution how to avoid this problem in Java8+?

Thank's for help!

1
-XX:-UseSplitVerifier does not work with Java 8 anymore. The only solution is to update the tools to versions with correct stackmap support. There were ten years time… - Holger
Which version of maven-surefire-plugin do you use? - khmarbaise
First it was 2.18.1 then I changed it for the last one - 2.19.1. Nothing changed. - Andrew

1 Answers

1
votes

Byte code manipulation tools need to update the stack map frames of the code they change. Otherwise, a VerifierError is thrown as it is happening in your case. Disabling the validation of the stack map frames by demanding the old verifier (-XX:-UseSplitVerifier) is no longer supported in Java 8.

I assume that you uncovered a bug in Javassist which is aware of stack map frames and probably emmits them incorrectly. Try updating to the latest version of the library. If this does not work, create a reproduction of the error and file a bug.