Andrew
Andrew

Reputation: 141

Inconsistent stackmap frames at branch - Java8 Maven Unit Testing

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!

Upvotes: 1

Views: 649

Answers (1)

Rafael Winterhalter
Rafael Winterhalter

Reputation: 44032

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.

Upvotes: 1

Related Questions