It is because of Java/Mockito compatibility. For example, if you are using Java 11 with Mockito 2.17.0, it will throw the same error (Upgrading to Mockito 2.22.0 or later will solve it). Aside from digging into their release artifact on Github, I am yet to see a comprehensive document that spells out the compatibility matrix. Here is a helpful compatibility Matrix (based on quick test)
- Mockito * – 2.17.0 => Java 8
(footnote: * – dont know how far back)
- Mockito 2.18.0 – 3.2.4 => Java 11