I am also getting the same error. Reverting back to `2.23.+` fixes the issue. Seems like you are loading the wrong version of ByteBuddy. What version are
you using?

On Mon, 4 Feb 2019, 10:49 Taher, <notifications@github.com> wrote:

> I am also getting the same error. Reverting back to 2.23.+ fixes the
> issue.
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/mockito/mockito/issues/1606#issuecomment-460203942>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AFrDb00_6nD1ZzQkmmEe6lbYHNFnz_8Yks5vKBBTgaJpZM4ag8uJ>
> .
>
 Hi Tim,

The ByteBuddy version I use is 1.9.3 That version is too low. Mockito depends on ByteBuddy 1.9.7: https://github.com/mockito/mockito/blob/aacacb156166b54b7eba3dfe03dd7bacda54c8d8/gradle/dependencies.gradle#L7 Also shown in the pom: http://central.maven.org/maven2/org/mockito/mockito-core/2.24.0/mockito-core-2.24.0.pom It seems like your project setup does not correctly resolve dependency mismatches. Had the same issue even though we never set bytebuddy as dependency somewhere.
Setting bytebuddy dependency explicitly at gradle fixed it for me. Adding bytebuddy as a dependency did fix the problem. I would think Gradle manages this dependency himself.

Anyway, thanks for the help!  I had to add byte-buddy as well as an explicit dependency to our project. Is it valid behaviour to use byte-buddy during runtime, even though it's specified as just a compile-time dependency of mockito? Same error with the same versions of mockito and byte-buddy, but adding it explicitly doesn't solve the issue. The only difference is that I use Maven instead of Gradle. I would reopen this as an actual bug since 2.23.0 version doesn't have this issue and the lib should handle gracefully its own dependencies like this one. Since quite some people have the same issue, i've reopened the issue. Same issue here. Same goes for 2.25.0.

Reverting to 2.23.0 solves the problem. Could anyone produce a repository that shows the issue? I am preparing a repo that shows the issue (it may take a couple of days), but if both mockito and selenium are used in a single pom.xml, selenium 3.141.59's dependency on byte-buddy 1.8.15 causes that version of byte-buddy to be used instead of the version required by mockito. I am not sure what we on the Mockito team can do about that. If Maven resolves to a dependency that does not satisfy the constraints we declare in our pom, that seems like an issue of Maven. We need at least ByteBuddy 1.9.7. If a different dependency requires a lower version, I think you need to resolve that in your `pom.xml` by explicitly declaring the version of ByteBuddy.

Per https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Dependency_Scope I am not sure what other scope is more appropriate over `compile`. We need ByteBuddy during compilation to define our MockMaker and therefore we also need to use it when running any test. As explained in my issue #1671 we have the same problem (sorry for the duplicate, I hadn't seen this one).
After investigation, it seems that we have 2 ByteBuddy.
The first one is from hibernate-core-5.4.1 and is released byte-buddy 1.9.5
The second one is from mockito-core-2.25.1 and is released byte-buddy 1.9.7

For some reasons, it's the byte-buddy 1.9.5 from hibernate dependency that is used by mockito.

By exluding byte-buddy from hibernate dependency, we can fix the problem, but I'm not sure that we will not have any side effect on hibernate :-/

```
<dependency>
	<groupId>org.hibernate</groupId>
	<artifactId>hibernate-core</artifactId>
	<version>5.4.1</version>
	<exclusions>
		<exclusion>
			<artifactId>byte-buddy</artifactId>
			<groupId>net.bytebuddy</groupId>
		</exclusion>
	</exclusions>
</dependency>
```

 Good catch, @marcam. If you go to https://mvnrepository.com/artifact/org.hibernate/hibernate-core/5.4.1.Final you can check that Hibernate will work well with any version until 1.9.10 (see update column in the dependencies table). So you can safely add the exclusion or include a new dependency in Maven to make clear what version you really want to use (my approach) Thank you @borjapenman 
Hibernate 5.4.2 is just released this morning with bytebuddy 1.9.10 and solves the problem without doing any exeption :-)
mockito uses now the 1.9.10 instead of 1.9.7

![image](https://user-images.githubusercontent.com/854436/54822157-a77f5c00-4ca4-11e9-82f1-b3d000b75541.png)
 @TimvdLippe, @raphw, shall we bump bytebuddy in Mockito? I'm curious: if it is a good time to start shadowing bytebuddy just like had in the past with cglib. This ticket is an evidence of the impact to our users when bytebuddy versions don't agree. I dont bumping the version is going to help. The dependency mechanisms in Maven and Gradle are fundamentally working against us.

I think shadowing is a good alternative. We should carefully evaluate the downsides, but to me it seems like the best option we have available. I don't think shadowing is a good alternative as this forces Mockito updates when updating to a new Java version rather the polling the newest Byte Buddy. 

Those resolution breakages are unfortunate but should be rare as we do not often require new APIs in Mockito.  I also don't like the idea with shadowing, especially as bute-buddy is (usually ;) ) backward compatible withing sane versioning scheme.
Gradle should use the higher version by default. Maven seems to use a different approach.

Regarding dependency bumping, @mockitoguy could you please consider adding a Dependabot app from the GitHub [marketplace](https://github.com/marketplace/dependabot/) (just for the mockito repository) to do it for us automatically (via PRs)? See the sample generated [PRs](https://github.com/szpak/mockito/pulls) in my fork. The configuration itself was merged in #1600. OK, thank you for consideration! Let's avoid shadowing.

@szpak, I'll check dependabot! Based on the Twitter discussion we had with Maven + Gradle, I will perform an investigation in all possible options. Hopefully I can finish that next week, but not sure when.

The TLDR is that the "closest wins" mechanism by Maven results in the usage of a version of ByteBuddy that is too old. We can specify our ByteBuddy version differently with `[1.2.3,)`, but I am not sure if that has unexpected side-effects. That's what I want to investigate. > Based on the Twitter discussion we had with Maven + Gradle, I will perform an investigation in all possible options

If Hibernate wants 1.9.10 and mockito-core wants 1.9.7, and those versions are not compatible, then I'm not sure what you want the build system to do. It won't be resolved automatically. Our options:

 a) shadowing
 b) mockito-core bumps to 1.9.10
 c) hibernate downgrades to 1.9.7
 d) we tell customers to downgrade/force to 1.9.7 and _hope_ that hibernate will work

Some of those options are clearly not viable. Opened https://github.com/mockito/mockito/pull/1673 > If Hibernate wants 1.9.10 and mockito-core wants 1.9.7, and those versions are not compatible, then I'm not sure what you want the build system to do. It won't be resolved automatically.

But the versions are compatible. We can simple use 1.9.10 and make them both work. That's because ByteBuddy follows semver (afaik). Yes, Byte Buddy follows semver. I had some hickups in the past, but given the libraries spread, I think the amount of incidents was minimal.

The reason I dislike the shadowing approach is that this would mean that any library should shadow all dependencies to avoid any possible conflict. This is a problem that should be solved in dependency resolution. I keep getting the same error i.e 
"Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list."

I have updated my gradle dependencies to match :

https://mvnrepository.com/artifact/org.mockito/mockito-core/2.25.0

mockito : "2.25.0"
mockito-core : "2.25.0"

I dont need bytebuddy dependency but added it to override any old dependencies
byte-buddy : 1.9.11
byte-buddy-agent : 1.9.11

Can someone suggest , what am I doing wrong ? > But the versions are compatible

Oh, then I misread this ticket. So I don't know what the problem is :) We are getting this when attempting to upgrade Spring Boot 2.0.x to 2.1.x.

spring-boot-dependencies specifies the version for ByteBuddy and Mockito:

Spring Boot 2.0:
```xml
<byte-buddy.version>1.7.11</byte-buddy.version>
<mockito.version>2.15.0</mockito.version>
```

Spring Boot 2.1:
```xml
<byte-buddy.version>1.9.10</byte-buddy.version>
<mockito.version>2.23.4</mockito.version>
```

We are using ``spy`` on a real class and it is fully public and non-final.

Any version of Mockito newer than 2.15.0 seems to cause this. 2.16.0 uses byte-buddy 1.9.10. Any idea on what I can look for? @efenderbosch Are you sure ByteBuddy is not loaded transitively through a different dependency? Yes, running ``mvn dependency:tree`` only shows 1.7.11 or 1.9.10 and only through Mockito.

We are still running Java 8, if that matters. Need Pact to update (4.x is currently in beta) so we can upgrade to 11. Was there a change in Mockito 2.16+ or ByteBuddy 1.8+ that doesn't work w/ Java 8? > 1.7.11

That version is too low and probably leads to the tests loading the wrong version of ByteBuddy. Could you specify ByteBuddy as a dependency in your root pom to use the correct version?

> Was there a change in Mockito 2.16+ or ByteBuddy 1.8+ that doesn't work w/ Java 8?

No, Mockito should work just fine on Java 8 ByteBuddy 1.7.11 and Mockito 2.15.0 *work*, though. Anything after that uses ByteBuddy 1.9.10+ and fails.

edit:
ok specified
```xml
<mockito.version>2.15.0</mockito.version>
<byte-buddy.version>1.7.11</byte-buddy.version>
```
in our parent pom and it still fails. I'm very confused now.

``mvn dependency:tree`` shows this:

```
[INFO] |  +- org.mockito:mockito-core:jar:2.15.0:test
[INFO] |  |  +- net.bytebuddy:byte-buddy:jar:1.7.11:provided
[INFO] |  |  \- net.bytebuddy:byte-buddy-agent:jar:1.7.11:test
```

with no other versions of Mockito or ByteBuddy.  Ok, I think I figured it out. The problem seems to be ``default`` methods on interfaces.

The class I'm spying implements ``com.github.benmanes.caffeine.cache.CacheLoader``

If my concrete class overrides the ``default`` methods, then my test runs successfully. @efenderbosch Please open a new issue (or PR if you can :smile: ) to triage your problem there. @efenderbosch This was strange. Can you create a small reproduction of the issue? I tried w/ a clean project and can't reproduce it. Gave up on Spring Boot 2.1 for now. Tried 2.0.9 (from 2.0.8) and got the same issue. So I'm pretty stumped as to what is going on. At this point, we are fine w/ just overriding default methods on the couple classes that we need to mock/spy. My colleague run into the same issue after recent upgrade to
'mockito-core', version: '2.25.0'
'powermock-api-mockito2', version: '2.0.0'
'powermock-module-junit4', version: '2.0.0'. 

Downgrading mockito-core to 2.23.0 helped to solve it. Strangely, it happens only running tests individually from IDEA, but they work fine running via Gradle script. Also, I was not able to reproduce it on my machine, though we have very similar environment setups.

Error message:

org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.fasterxml.jackson.databind.ObjectMapper.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.

Java               : 1.8
JVM vendor name    : Oracle Corporation
JVM vendor version : 25.191-b12
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_191-b12
JVM info           : mixed mode
OS name            : Windows 10
OS version         : 10.0

Underlying exception : java.lang.IllegalArgumentException: Could not create type Hi I have the same problem. I am migrating from java 8 to java 11. I have updated Mockito to 2.23.0 

`[INFO] +- org.mockito:mockito-core:jar:2.23.0:compile`

I have also included byte-buddy as a dependency 
```
[INFO] +- net.bytebuddy:byte-buddy:jar:1.9.7:compile
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.9.7:compile

```
I have checked that byte-buddy is not loaded transitively through a different dependency. I can't understand what the issue is. Do you have a stack trace? There can be other errors causing this message. @raphw The stack trace is almost the same as others. Here you go
```
org.mockito.exceptions.base.MockitoException: 

Mockito cannot mock this class: class javax.ws.rs.core.Response.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.


Java               : 11
JVM vendor name    : Oracle Corporation
JVM vendor version : 11.0.2+9-LTS
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 11.0.2+9-LTS
JVM info           : mixed mode
OS name            : Linux
OS version         : 4.9.125-linuxkit

Underlying exception : java.lang.IllegalStateException: Error invoking java.lang.reflect.Method#getAnnotatedReturnType
``` @MoodyMudit It's unlikely that is the full stacktrace. Could you post the full stacktrace please? It still shows the error with *Error invoking java.lang.reflect.Method#getAnnotatedReturnType*. Seems like a problem with your mocked class. @TimvdLippe @raphw I was able to solve this issue. I noticed that java 11 does not contain the JAXB APIs. So I included them as dependencies in pom.

```
<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-impl</artifactId>
    <version>2.2.11</version>
</dependency>
<dependency>
    <groupId>javax.activation</groupId>
    <artifactId>activation</artifactId>
    <version>1.1.1</version>
</dependency>
```
Thanks for your help. > 嗨，
> 
> 从版本2.24.0开始，我收到错误“Mockito只能模拟非私有和非最终类。”。回到Mockito 2.23.4解决了这个问题。
> 
> **堆栈跟踪**
> `Underlying exception : java.lang.IllegalArgumentException: Could not create type at nl.tkp.ddw.pensioenaangifte.test.model.unittesten.AanleveringFilteringStepDefinitions.setup(AanleveringFilteringStepDefinitions.java:43) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at cucumber.runtime.Utils$1.call(Utils.java:26) at cucumber.runtime.Timeout.timeout(Timeout.java:16) at cucumber.runtime.Utils.invoke(Utils.java:20) at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60) at cucumber.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:16) at cucumber.runner.TestStep.executeStep(TestStep.java:63) at cucumber.runner.TestStep.run(TestStep.java:49) at cucumber.runner.TestCase.run(TestCase.java:40) at cucumber.runner.Runner.runPickle(Runner.java:40) at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68) at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73) at cucumber.api.junit.Cucumber.runChild(Cucumber.java:124) at cucumber.api.junit.Cucumber.runChild(Cucumber.java:65) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:133) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58) at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38) at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62) at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32) at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93) at com.sun.proxy.$Proxy2.processTestClass(Unknown Source) at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35) at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175) at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157) at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.IllegalArgumentException: Could not create type at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154) at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365) at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174) at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71) at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42) at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25) at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35) at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62) at org.mockito.Mockito.mock(Mockito.java:1896) at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44) at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19) at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16) at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38) at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62) at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:49) at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41) at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69) ... 63 more Caused by: java.lang.NoSuchMethodError: net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific(Ljava/util/Collection;)Lnet/bytebuddy/dynamic/loading/MultipleParentClassLoader$Builder; at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:83) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37) at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34) at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152) ... 81 more`
> 
> **Versioninfo**
> Java：1.8 
> JVM供应商名称：Oracle Corporation 
> JVM供应商版本：25.191-b12 
> JVM名称：Java HotSpot（TM）64位服务器VM 
> JVM版本：1.8.0_191-b12 
> JVM信息：混合模式
> 操作系统名称：Mac OS X 
> OS版本：10.13.6 
> Mockito-core：2.24.0

我也遇到了 快点修复 I have the same problem with 2.27.0, reverting back to 2.23.4 works.

> Interface that Mockito is unable to mock

```java

import java.util.Set;

import br.com.senior.platform.authorization.UserNotificationPriority;
import br.com.senior.platform.authorization.model.ResourceIntegration;

public interface NotifyResourceIntegration {

    boolean notifyOnError(Set<ResourceIntegration> allResources, Throwable ex, String tenant);

    void notifyUser(UserNotificationPriority priority, String content, String tenant);
}
```

>  Full stack trace


```
org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: interface br.com.senior.platform.authorization.service.notification.NotifyResourceIntegration.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.


Java               : 11
JVM vendor name    : Oracle Corporation
JVM vendor version : 11.0.2+9
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 11.0.2+9
JVM info           : mixed mode
OS name            : Windows 10
OS version         : 10.0


Underlying exception : java.lang.IllegalArgumentException: Could not create type

	at br.com.senior.platform.authorization.service.notification.NotifyServiceImplTest.setUp(NotifyServiceImplTest.java:38)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
	at org.mockito.Mockito.mock(Mockito.java:1907)
	at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:49)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
	at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
	... 23 more
Caused by: java.lang.NoSuchMethodError: net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific(Ljava/util/Collection;)Lnet/bytebuddy/dynamic/loading/MultipleParentClassLoader$Builder;
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:83)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
	... 41 more

``` @luankevinferreira You are loading a too-old version of ByteBuddy. Check the version you are using and upgrade it to the one compatible with the version specified in the Mockito pom. > My colleague run into the same issue after recent upgrade to
> 'mockito-core', version: '2.25.0'
> 'powermock-api-mockito2', version: '2.0.0'
> 'powermock-module-junit4', version: '2.0.0'.
> 
> Downgrading mockito-core to 2.23.0 helped to solve it. Strangely, it happens only running tests individually from IDEA, but they work fine running via Gradle script. Also, I was not able to reproduce it on my machine, though we have very similar environment setups.
> 
> Error message:
> 
> org.mockito.exceptions.base.MockitoException:
> Mockito cannot mock this class: class com.fasterxml.jackson.databind.ObjectMapper.
> 
> Mockito can only mock non-private & non-final classes.
> If you're not sure why you're getting this error, please report to the mailing list.
> 
> Java : 1.8
> JVM vendor name : Oracle Corporation
> JVM vendor version : 25.191-b12
> JVM name : Java HotSpot(TM) 64-Bit Server VM
> JVM version : 1.8.0_191-b12
> JVM info : mixed mode
> OS name : Windows 10
> OS version : 10.0
> 
> Underlying exception : java.lang.IllegalArgumentException: Could not create type

I actually encountered this same issue today. What caused the problem for me was a dependency combination misconfiguration: I have a config "compile" that takes Hibernate-osgi 2.5.17Final, which depends on byte-buddy 1.6.14. I have a config "test" that takes mockito 2.27.0, which depends on byte-buddy 1.9.10. When running my unittests from my IDE, it properly combined those dependencies including version management, but when I ran it from an Ant script, I had to manually merge these 2 configurations into a class Path. I put the compile config first, which meant the Byte-Buddy of Hibernate was used by Mockito instead of the one Mockito had to use. We considered putting the test config first, but that would actually mean we would test with a different version of ByteBuddy than we use in the main configuration.

upgrading Hibernate would currently be too involved, but we are planning to do so later for Java 11 support. For now, we're downgrading Mockito. 
I am getting the below error when using Mockito. Is it related to this issue?

```
Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/adapters/XmlAdapter
    [junit] 	at java.base/java.lang.Class.getDeclaringClass0(Native Method)
    [junit] 	at java.base/java.lang.Class.getEnclosingClass(Class.java:1518)
    [junit] 	at java.base/java.lang.reflect.Executable.getAnnotatedReturnType0(Executable.java:642)
    [junit] 	at java.base/java.lang.reflect.Method.getAnnotatedReturnType(Method.java:721)
    [junit] 	at java.base/jdk.internal.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
    [junit] 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [junit] 	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedReturnType.resolve(TypeDescription.java:2928)
``` @karthickpdy Unrelated. Is javax.xml.bind on the classpath? If you're on jdk >= 11 JAXB is removed from the JDK. Seems like an annotation is loaded during instrumentation that is indeed missing on the class path.

If you just try to load this class where the mock is created, is the same exception thrown? Seeing following with 2.23.0 / OpenJDK Runtime Environment 18.9 (build 11.0.2+9), works fine with Java 8.
org.mockito:mockito-core:2.23.0
   net.bytebuddy:byte-buddy:1.9.0
   net.bytebuddy:byte-buddy-agent:1.9.0
   org.objenesis:objenesis:2.6

> 

> org.mockito.exceptions.base.MockitoException: 
> Mockito cannot mock this class: class javax.ws.rs.core.Response.
> 
> Mockito can only mock non-private & non-final classes.
> If you're not sure why you're getting this error, please report to the mailing list.
> 
> 
> Java               : 11
> JVM vendor name    : Oracle Corporation
> JVM vendor version : 11.0.2+9
> JVM name           : OpenJDK 64-Bit Server VM
> JVM version        : 11.0.2+9
> JVM info           : mixed mode
> OS name            : Windows 10
> OS version         : 10.0
> 
> 
> Underlying exception : java.lang.IllegalStateException: Error invoking java.lang.reflect.Method#getAnnotatedReturnType
> 	at com.MyTest.setup(MyTest.java:72)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> 	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> 	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
> 	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
> 	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:24)
> 	at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:239)
> 	at org.junit.rules.RunRules.evaluate(RunRules.java:20)
> 	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
> 	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
> 	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
> 	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
> 	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
> 	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
> 	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
> 	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
> 	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
> 	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
> 	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
> 	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
> 	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> 	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
> 	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
> 	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
> 	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
> 	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
> 	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> 	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
> 	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
> 	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
> 	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
> 	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
> 	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
> 	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> 	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
> 	at java.base/java.lang.Thread.run(Thread.java:834)
> Caused by: java.lang.IllegalStateException: Error invoking java.lang.reflect.Method#getAnnotatedReturnType
> 	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedReturnType.resolve(TypeDescription.java:2932)
> 	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Delegator.asList(TypeDescription.java:3186)
> 	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType$ForLoadedType.getDeclaredAnnotations(TypeDescription.java:3872)
> 	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.apply(AnnotationAppender.java:669)
> 	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:650)
> 	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:353)
> 	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType.accept(TypeDescription.java:3662)
> 	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$ForInstrumentedMethod.apply(MethodAttributeAppender.java:181)
> 	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$Compound.apply(MethodAttributeAppender.java:449)
> 	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyAttributes(TypeWriter.java:691)
> 	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyBody(TypeWriter.java:681)
> 	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod.apply(TypeWriter.java:590)
> 	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForCreation.create(TypeWriter.java:5114)
> 	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1915)
> 	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:197)
> 	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:174)
> 	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3376)
> 	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:3565)
> 	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:128)
> 	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
> 	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
> 	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:137)
> 	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:350)
> 	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:159)
> 	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:361)
> 	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
> 	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
> 	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
> 	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
> 	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
> 	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:69)
> 	at org.mockito.Mockito.mock(Mockito.java:1895)
> 	at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:41)
> 	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
> 	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
> 	at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
> 	at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
> 	at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:57)
> 	at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
> 	at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
> 	... 50 more
> Caused by: java.lang.NoClassDefFoundError: javax/xml/bind/annotation/adapters/XmlAdapter
> 	at java.base/java.lang.Class.getDeclaringClass0(Native Method)
> 	at java.base/java.lang.Class.getEnclosingClass(Class.java:1518)
> 	at java.base/sun.reflect.annotation.AnnotatedTypeFactory.nestingForType(AnnotatedTypeFactory.java:96)
> 	at java.base/sun.reflect.annotation.TypeAnnotationParser.buildAnnotatedType(TypeAnnotationParser.java:79)
> 	at java.base/java.lang.reflect.Executable.getAnnotatedReturnType0(Executable.java:642)
> 	at java.base/java.lang.reflect.Method.getAnnotatedReturnType(Method.java:721)
> 	at java.base/jdk.internal.reflect.GeneratedMethodAccessor23.invoke(Unknown Source)
> 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
> 	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedReturnType.resolve(TypeDescription.java:2928)
> 	... 89 more
> ` > As explained in my issue #1671 we have the same problem (sorry for the duplicate, I hadn't seen this one).
> After investigation, it seems that we have 2 ByteBuddy.
> The first one is from hibernate-core-5.4.1 and is released byte-buddy 1.9.5
> The second one is from mockito-core-2.25.1 and is released byte-buddy 1.9.7
> 
> For some reasons, it's the byte-buddy 1.9.5 from hibernate dependency that is used by mockito.
> 
> By exluding byte-buddy from hibernate dependency, we can fix the problem, but I'm not sure that we will not have any side effect on hibernate :-/
> 
> ```
> <dependency>
> 	<groupId>org.hibernate</groupId>
> 	<artifactId>hibernate-core</artifactId>
> 	<version>5.4.1</version>
> 	<exclusions>
> 		<exclusion>
> 			<artifactId>byte-buddy</artifactId>
> 			<groupId>net.bytebuddy</groupId>
> 		</exclusion>
> 	</exclusions>
> </dependency>
> ```

This worked for me. I added `byte-buddy` and `byte-buddy-agent` dependencies to my pom file in the version **1.9.7**.

It was like the following:

```
                <dependency>
			<groupId>net.bytebuddy</groupId>
			<artifactId>byte-buddy</artifactId>
			<version>1.9.7</version>
			<scope>test</scope>
		</dependency>
		<dependency>
			<groupId>net.bytebuddy</groupId>
			<artifactId>byte-buddy-agent</artifactId>
			<version>1.9.7</version>
			<scope>test</scope>
		</dependency>
```

Also, I excluded those dependencies in `hibernate-core` and `hibernate-entitymanager` because those dependencies contains the `byte-buddy` and `byte-buddy-agent` in a prior version. In **Eclipse** make sure to add as external library byte buddy. Ctrl + right click on project > Java Build Path > Libraries > Add external JARS > byte-buddy-1.**.*.jar
This worked for me if you want to debug your Junit tests in Eclipse I am still getting this issue with Mockito `3.0.0` (and `mockito-android`) when running Android instrumentation tests:

```
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class com.(...)._MyClass_.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.

IMPORTANT INFORMATION FOR ANDROID USERS:

The regular Byte Buddy mock makers cannot generate code on an Android VM!
To resolve this, please use the 'mockito-android' dependency for your application:
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22

Java               : 0.9
JVM vendor name    : The Android Project
JVM vendor version : 2.1.0
JVM name           : Dalvik
JVM version        : 0.9
JVM info           : null
OS name            : Linux
OS version         : 3.18.71-g7dfaee7f928


Underlying exception : java.lang.IllegalArgumentException: Could not create type
at _com.(...).MyTest_.setUp(MyTest.java:44)
at java.lang.reflect.Method.invoke(Native Method)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
(...)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2074)
Caused by: java.lang.IllegalArgumentException: Could not create type
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
at org.mockito.android.internal.creation.AndroidByteBuddyMockMaker.createMock(AndroidByteBuddyMockMaker.java:39)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
at org.mockito.Mockito.mock(Mockito.java:1908)
at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:49)
at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
... 30 more
Caused by: java.lang.NoSuchFieldError: No instance field targetApiLevel of type I in class Lcom/android/dx/dex/DexOptions; or its superclasses (declaration of 'com.android.dx.dex.DexOptions' appears in /data/app/com.teamwork.projects.data.test-WeFv56g4F9J4rFDV8asMpg==/base.apk)
at net.bytebuddy.android.AndroidClassLoadingStrategy$DexProcessor$ForSdkCompiler.makeDefault(AndroidClassLoadingStrategy.java:216)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting.<init>(AndroidClassLoadingStrategy.java:387)
at org.mockito.android.internal.creation.AndroidLoadingStrategy.resolveStrategy(AndroidLoadingStrategy.java:39)
at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:173)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
... 48 more
``` What dex compiler did you bundle with Android here? Seems like the API is not compatible. I'm using Studio 3.5 and Gradle build tools 3.5.0, so it's using D8 by default I guess. Getting this on `mockito-android:3.1.0` (instrumented tests) especially on `release` build, on `debug` it works fine.
```
    classpath 'com.android.tools.build:gradle:3.5.0'

android {
  buildTypes {
    buildToolsVersion "28.0.3"
    release {
      minifyEnabled false
```   I'm seeing a similar error running Mockito 3.10.0 or 2.23.4, it doesn't make a difference. I've tried running on an Android 10 phone, as well as on a emulator sdk 27

```
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class android.content.Context.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.



IMPORTANT INFORMATION FOR ANDROID USERS:

The regular Byte Buddy mock makers cannot generate code on an Android VM!
To resolve this, please use the 'mockito-android' dependency for your application:
http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22

Java               : 0.9
JVM vendor name    : The Android Project
JVM vendor version : 2.1.0
JVM name           : Dalvik
JVM version        : 0.9
JVM info           : null
OS name            : Linux
OS version         : 3.18.91+


Underlying exception : java.lang.IllegalArgumentException: Could not create type
at com.mycomp.android.sdk.core.driver.ble.nordic.MyTest.<init>(MyTest.kt:301)
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at org.junit.runners.BlockJUnit4ClassRunner.createTest(BlockJUnit4ClassRunner.java:217)
at org.junit.runners.BlockJUnit4ClassRunner$1.runReflectiveCall(BlockJUnit4ClassRunner.java:266)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at androidx.test.ext.junit.runners.AndroidJUnit4.run(AndroidJUnit4.java:104)
at org.junit.runners.Suite.runChild(Suite.java:128)
at org.junit.runners.Suite.runChild(Suite.java:27)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:388)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2075)
Caused by: java.lang.IllegalArgumentException: Could not create type
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
at org.mockito.android.internal.creation.AndroidByteBuddyMockMaker.createMock(AndroidByteBuddyMockMaker.java:39)
at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
at org.mockito.Mockito.mock(Mockito.java:1908)
... 29 more
Caused by: java.lang.NoSuchFieldError: No instance field targetApiLevel of type I in class Lcom/android/dx/dex/DexOptions; or its superclasses (declaration of 'com.android.dx.dex.DexOptions' appears in /data/app/com.mycomp.android.sdk.test-akjnnaFvI2s0R5IuilGDvg==/base.apk)
at net.bytebuddy.android.AndroidClassLoadingStrategy$DexProcessor$ForSdkCompiler.makeDefault(AndroidClassLoadingStrategy.java:216)
at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting.<init>(AndroidClassLoadingStrategy.java:387)
at org.mockito.android.internal.creation.AndroidLoadingStrategy.resolveStrategy(AndroidLoadingStrategy.java:39)
at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:173)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
... 39 more
```

To provide more context, this happens after adding MockK Android (https://mockk.io/ANDROID.html). The only suspicious dependency I see is `dexmaker:2.21.0`. I've forced it to use dexmaker:2.25.0, which upgrades to mockito 2.25.0, but still no luck

 Android has been changing its APIs in a non-compatible manner again, this causes these problems. I would have to look into supporting newer API versions in the DEX compiler. If you are also using MOCKK, I assume that the problem is the dexmaker version, you are very likely on the right track. if anyone is still getting the error in spring-boot project, it could be because spring provides its version of byte-buddy. 
adding `<byte-buddy.version>1.9.7</byte-buddy.version>` will tell maven to use the newer version. > I am still getting this issue with Mockito `3.0.0` (and `mockito-android`) when running Android instrumentation tests:
> 
> ```
> org.mockito.exceptions.base.MockitoException:
> Mockito cannot mock this class: class com.(...)._MyClass_.
> 
> Mockito can only mock non-private & non-final classes.
> If you're not sure why you're getting this error, please report to the mailing list.
> 
> IMPORTANT INFORMATION FOR ANDROID USERS:
> 
> The regular Byte Buddy mock makers cannot generate code on an Android VM!
> To resolve this, please use the 'mockito-android' dependency for your application:
> http://search.maven.org/#search%7Cga%7C1%7Ca%3A%22mockito-android%22%20g%3A%22org.mockito%22
> 
> Java               : 0.9
> JVM vendor name    : The Android Project
> JVM vendor version : 2.1.0
> JVM name           : Dalvik
> JVM version        : 0.9
> JVM info           : null
> OS name            : Linux
> OS version         : 3.18.71-g7dfaee7f928
> 
> 
> Underlying exception : java.lang.IllegalArgumentException: Could not create type
> at _com.(...).MyTest_.setUp(MyTest.java:44)
> at java.lang.reflect.Method.invoke(Native Method)
> at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
> (...)
> at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
> at androidx.test.internal.runner.TestExecutor.execute(TestExecutor.java:56)
> at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:392)
> at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2074)
> Caused by: java.lang.IllegalArgumentException: Could not create type
> at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
> at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
> at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
> at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
> at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
> at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
> at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
> at org.mockito.android.internal.creation.AndroidByteBuddyMockMaker.createMock(AndroidByteBuddyMockMaker.java:39)
> at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
> at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
> at org.mockito.Mockito.mock(Mockito.java:1908)
> at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44)
> at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
> at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
> at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
> at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
> at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:49)
> at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
> at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
> ... 30 more
> Caused by: java.lang.NoSuchFieldError: No instance field targetApiLevel of type I in class Lcom/android/dx/dex/DexOptions; or its superclasses (declaration of 'com.android.dx.dex.DexOptions' appears in /data/app/com.teamwork.projects.data.test-WeFv56g4F9J4rFDV8asMpg==/base.apk)
> at net.bytebuddy.android.AndroidClassLoadingStrategy$DexProcessor$ForSdkCompiler.makeDefault(AndroidClassLoadingStrategy.java:216)
> at net.bytebuddy.android.AndroidClassLoadingStrategy$Injecting.<init>(AndroidClassLoadingStrategy.java:387)
> at org.mockito.android.internal.creation.AndroidLoadingStrategy.resolveStrategy(AndroidLoadingStrategy.java:39)
> at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:173)
> at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
> at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
> at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
> ... 48 more
> ```

Getting same exception for Unit test cases.
Mockito - 3.1.0
Powermock - 2.0.4

You are able to solve this issue. if yes please give us the solution. Try using the newest version of Byte Buddy explicitly. I recently adjusted the code to work with Android's newer API versions. > Try using the newest version of Byte Buddy explicitly. I recently adjusted the code to work with Android's newer API versions.

Tried but no luck

Here is the log


```
org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: class android.content.Context.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.


Java               : 1.8
JVM vendor name    : JetBrains s.r.o
JVM vendor version : 25.202-b49-5587405
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 1.8.0_202-release-1483-b49-5587405
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 10.14.6


Underlying exception : java.lang.IllegalStateException: Error invoking java.lang.reflect.Executable#getAnnotatedExceptionTypes

	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalStateException: Error invoking java.lang.reflect.Executable#getAnnotatedExceptionTypes
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedExceptionType.resolve(TypeDescription.java:3029)
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Delegator.asList(TypeDescription.java:3201)
	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType$ForLoadedType.getDeclaredAnnotations(TypeDescription.java:3887)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.apply(AnnotationAppender.java:690)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:671)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:374)
	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType.accept(TypeDescription.java:3677)
	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$ForInstrumentedMethod.apply(MethodAttributeAppender.java:218)
	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$Compound.apply(MethodAttributeAppender.java:484)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyAttributes(TypeWriter.java:706)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyBody(TypeWriter.java:696)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod.apply(TypeWriter.java:605)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForCreation.create(TypeWriter.java:5133)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:1933)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:225)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:198)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3404)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:3600)
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:172)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.powermock.api.mockito.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:41)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:63)
	at org.mockito.Mockito.mock(Mockito.java:1908)
	at org.mockito.Mockito.mock(Mockito.java:1817)

	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.internal.runners.TestMethod.invoke(TestMethod.java:68)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:326)
	at org.junit.internal.runners.MethodRoadie$2.run(MethodRoadie.java:89)
	at org.junit.internal.runners.MethodRoadie.runBeforesThenTestThenAfters(MethodRoadie.java:97)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:310)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)
	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:117)
	at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
	at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
	... 5 more
Caused by: java.lang.NoClassDefFoundError: android/content/IntentSender$FinishedDispatcher
	at java.lang.Class.getDeclaringClass0(Native Method)
	at java.lang.Class.getDeclaringClass(Class.java:1235)
	at java.lang.Class.getEnclosingClass(Class.java:1277)
	at sun.reflect.annotation.AnnotatedTypeFactory.addNesting(AnnotatedTypeFactory.java:96)
	at sun.reflect.annotation.AnnotatedTypeFactory.buildAnnotatedType(AnnotatedTypeFactory.java:65)
	at sun.reflect.annotation.TypeAnnotationParser.buildAnnotatedTypes(TypeAnnotationParser.java:158)
	at java.lang.reflect.Executable.getAnnotatedExceptionTypes(Executable.java:718)
	at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedExceptionType.resolve(TypeDescription.java:3025)
	... 65 more
``` Are there any updates on this?
I've tried with Mockito `3.2.4`, any possible combination of Byte Buddy versions and excluding it from other testing libraries that use it, no luck.
Still can't run instrumentation tests if I'm using MockK > `1.9` in the same module. I think I may have found the culprit: the newer Dexmaker version MockK is using.
I've managed to get rid of the issue in my project with the latest version of the two libs by doing this:

```
androidTestImplementation("org.mockito:mockito-android:3.2.4")
androidTestImplementation("io.mockk:mockk-android:1.9.3") {
      exclude module: 'dexmaker'
}
androidTestImplementation "com.linkedin.dexmaker:dexmaker:2.12.1" // newer versions break Mockito
``` Hi all, I have a similar problem.  I have the error around trying to mock an interface that utilizes JDBI 2.  I've tried various combinations of mockito-core around 2.23.* and 2.24.* and manually setting the byte-buddy version.  I currently have 2.23.4 and byte buddy 1.9.11

I'll include the error and some of the dependency tree.  Any ideas?
```
org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: interface com.groupon.da.aesservice.jdbi.CustomerDbi.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.


Java               : 1.8
JVM vendor name    : Oracle Corporation
JVM vendor version : 25.172-b11
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_172-b11
JVM info           : mixed mode
OS name            : Mac OS X
OS version         : 10.14.6


Underlying exception : java.lang.IllegalArgumentException: Could not create type

	at org.mockito.internal.runners.DefaultInternalRunner$1.withBefores(DefaultInternalRunner.java:39)
	at org.junit.runners.BlockJUnit4ClassRunner.methodBlock(BlockJUnit4ClassRunner.java:276)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.mockito.internal.runners.DefaultInternalRunner$1.run(DefaultInternalRunner.java:79)
	at org.mockito.internal.runners.DefaultInternalRunner.run(DefaultInternalRunner.java:85)
	at org.mockito.internal.runners.StrictRunner.run(StrictRunner.java:39)
	at org.mockito.junit.MockitoJUnitRunner.run(MockitoJUnitRunner.java:163)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
	at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
Caused by: java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.powermock.api.mockito.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:41)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:69)
	at org.mockito.Mockito.mock(Mockito.java:1896)
	at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:57)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
	at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
	... 19 more
Caused by: java.lang.annotation.AnnotationFormatError: Invalid default: public abstract java.lang.Class org.skife.jdbi.v2.sqlobject.stringtemplate.UseStringTemplate3StatementLocator.errorListener()
	at java.lang.reflect.Method.getDefaultValue(Method.java:612)
	at sun.reflect.annotation.AnnotationType.<init>(AnnotationType.java:132)
	at sun.reflect.annotation.AnnotationType.getInstance(AnnotationType.java:85)
	at sun.reflect.annotation.AnnotationParser.parseAnnotation2(AnnotationParser.java:266)
	at sun.reflect.annotation.AnnotationParser.parseAnnotations2(AnnotationParser.java:120)
	at sun.reflect.annotation.AnnotationParser.parseAnnotations(AnnotationParser.java:72)
	at java.lang.Class.createAnnotationData(Class.java:3521)
	at java.lang.Class.annotationData(Class.java:3510)
	at java.lang.Class.getAnnotations(Class.java:3446)
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:85)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
	... 38 more
```

Partial Dependency tree (lines with *byte* and *mock*)
```
[INFO] {myProject}
[INFO] +- net.bytebuddy:byte-buddy-agent:jar:1.9.11:test
[INFO] +- net.bytebuddy:byte-buddy:jar:1.9.11:test
[INFO] +- org.mockito:mockito-core:jar:2.23.4:test
[INFO] |  \- org.objenesis:objenesis:jar:3.0.1:test
[INFO] +- org.powermock:powermock-module-junit4:jar:2.0.2:test
[INFO] |  +- org.powermock:powermock-module-junit4-common:jar:2.0.2:test
[INFO] |  \- org.hamcrest:hamcrest-core:jar:1.3:test
[INFO] +- org.powermock:powermock-api-mockito2:jar:2.0.2:test
[INFO] |  \- org.powermock:powermock-api-support:jar:2.0.2:test
[INFO] +- org.powermock:powermock-core:jar:2.0.2:test
[INFO] |  +- org.powermock:powermock-reflect:jar:2.0.2:test
[INFO] |  \- org.javassist:javassist:jar:3.24.1-GA:compile
``` 


> I think I may have found the culprit: the newer Dexmaker version MockK is using.
> I've managed to get rid of the issue in my project with the latest version of the two libs by doing this:
> 
> ```
> androidTestImplementation("org.mockito:mockito-android:3.2.4")
> androidTestImplementation("io.mockk:mockk-android:1.9.3") {
>       exclude module: 'dexmaker'
> }
> androidTestImplementation "com.linkedin.dexmaker:dexmaker:2.12.1" // newer versions break Mockito
> ```

Thank you very much.

resolutionStrategy {
            force("com.linkedin.dexmaker:dexmaker:2.12.1")
} You don't need to exclude or declare the dexmaker dependency. The resolutionStrategy part works just fine Started getting this on Android after updating to Kotlin 1.4.0 with Mockito 3.5.2:

```
Mockito cannot mock this class: class android.content.Context.

Java               : 11
JVM vendor name    : Oracle Corporation
JVM vendor version : 11.0.8+10
JVM name           : OpenJDK 64-Bit Server VM
JVM version        : 11.0.8+10
JVM info           : mixed mode
OS name            : Linux
OS version         : 4.15.0-1077-aws
``` 

I'm not using Mockk anywhere, dexmaker isn't part of my dependencies tree and everything was working perfectly fine before updating the language. All tests are running against Android API 28, so pretty sure this isn't "Android changing its APIs in a non-compatible manner" as was previously mentioned. Is there no stack trace or anything? We had some quick bug fixes right after release. Could you try out the version just released?

Also, can you try to downgrade the implicit Objenesis dependency? It seems to break a lot of Android things due to its use of `MethodHandle`s. Thanks @raphw. I managed to isolate the issue. It seems CircleCI updated their JVM version to 11.0.8 without letting anyone know, and that caused several issues including this. Upgrading to Mockito's latest version and then instructing CircleCI to use JVM 8 fixes it. Hey @raphw, I am having the same issue. Can you please let me know how you instruct CircleCI to use JVM 8? I can't seem to find how to do it. I don't use CircleCI but @mradzinski can maybe help you out. Oh I am sorry @raphw, I tagged the wrong person. I meant to tag @mradzinski. However I updated the `mockito` libraries (we use `mockito-android` and `mockito-kotlin`) to the latest versions and our tests worked fine once again, I didn't have to mess with the CircleCI configuration. Thank you! Hi All,

I'm also seeing this error while mocking 
@Mock
private KafkaFactory mockKafkaFactory;

java.lang.RuntimeException: Invoking the beforeTestMethod method on PowerMock test listener org.powermock.api.extension.listener.AnnotationEnabler@770f8c86 failed.

	at org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:84)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:308)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)
	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:117)
	at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
	at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.Iterator.forEachRemaining(Iterator.java:116)
	at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:482)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:472)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
	at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
	at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
	at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
	at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
	at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
	at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
Caused by: org.mockito.exceptions.base.MockitoException: 
Mockito cannot mock this class: class com.vlocity.xom.kafka.KafkaFactory.

Mockito can only mock non-private & non-final classes.
If you're not sure why you're getting this error, please report to the mailing list.


Java               : 1.8
JVM vendor name    : Oracle Corporation
JVM vendor version : 25.251-b08
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 1.8.0_251-b08
JVM info           : mixed mode
OS name            : Windows 10
OS version         : 10.0


Underlying exception : java.lang.IllegalStateException: Error invoking java.lang.reflect.Executable#getAnnotatedParameterTypes
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	... 24 more
Caused by: java.lang.IllegalStateException: Error invoking java.lang.reflect.Executable#getAnnotatedParameterTypes
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedParameterizedType.resolve(TypeDescription.java:3025)
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Delegator.asList(TypeDescription.java:3238)
	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType$ForLoadedType.getDeclaredAnnotations(TypeDescription.java:3987)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.apply(AnnotationAppender.java:725)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:706)
	at net.bytebuddy.implementation.attribute.AnnotationAppender$ForTypeAnnotations.onNonGenericType(AnnotationAppender.java:409)
	at net.bytebuddy.description.type.TypeDescription$Generic$OfNonGenericType.accept(TypeDescription.java:3769)
	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$ForInstrumentedMethod.apply(MethodAttributeAppender.java:208)
	at net.bytebuddy.implementation.attribute.MethodAttributeAppender$Compound.apply(MethodAttributeAppender.java:484)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyAttributes(TypeWriter.java:701)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod$WithBody.applyBody(TypeWriter.java:691)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$MethodPool$Record$ForDefinedMethod.apply(TypeWriter.java:600)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default$ForCreation.create(TypeWriter.java:5660)
	at net.bytebuddy.dynamic.scaffold.TypeWriter$Default.make(TypeWriter.java:2166)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:232)
	at net.bytebuddy.dynamic.scaffold.subclass.SubclassDynamicTypeBuilder.make(SubclassDynamicTypeBuilder.java:204)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase.make(DynamicType.java:3595)
	at net.bytebuddy.dynamic.DynamicType$Builder$AbstractBase$Delegator.make(DynamicType.java:3819)
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:128)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.powermock.api.mockito.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:41)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:69)
	at org.mockito.Mockito.mock(Mockito.java:1895)
	at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMethodInvocationControl(DefaultMockCreator.java:108)
	at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.doCreateMock(DefaultMockCreator.java:61)
	at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.createMock(DefaultMockCreator.java:53)
	at org.powermock.api.mockito.internal.mockcreation.DefaultMockCreator.mock(DefaultMockCreator.java:40)
	at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:181)
	at org.powermock.api.extension.listener.AnnotationEnabler.standardInject(AnnotationEnabler.java:98)
	at org.powermock.api.extension.listener.AnnotationEnabler.beforeTestMethod(AnnotationEnabler.java:55)
	at org.powermock.tests.utils.impl.PowerMockTestNotifierImpl.notifyBeforeTestMethod(PowerMockTestNotifierImpl.java:82)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.executeTest(PowerMockJUnit44RunnerDelegateImpl.java:308)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTestInSuper(PowerMockJUnit47RunnerDelegateImpl.java:131)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.access$100(PowerMockJUnit47RunnerDelegateImpl.java:59)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner$TestExecutorStatement.evaluate(PowerMockJUnit47RunnerDelegateImpl.java:147)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.evaluateStatement(PowerMockJUnit47RunnerDelegateImpl.java:107)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:82)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:298)
	at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87)
	at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:218)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:160)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:134)
	at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34)
	at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44)
	at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:136)
	at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:117)
	at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:57)
	at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59)
	... 24 more
Caused by: java.lang.NullPointerException
	at sun.reflect.annotation.TypeAnnotationParser.mapTypeAnnotations(TypeAnnotationParser.java:356)
	at sun.reflect.annotation.AnnotatedTypeFactory$AnnotatedTypeBaseImpl.<init>(AnnotatedTypeFactory.java:139)
	at sun.reflect.annotation.AnnotatedTypeFactory.buildAnnotatedType(AnnotatedTypeFactory.java:65)
	at sun.reflect.annotation.TypeAnnotationParser.buildAnnotatedTypes(TypeAnnotationParser.java:137)
	at java.lang.reflect.Executable.getAnnotatedParameterTypes(Executable.java:688)
	at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at net.bytebuddy.description.type.TypeDescription$Generic$AnnotationReader$Dispatcher$ForJava8CapableVm$AnnotatedParameterizedType.resolve(TypeDescription.java:3021)
	... 82 more



Dependency tree:
+- org.springframework.boot:spring-boot-starter-test:jar:2.3.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test:jar:2.3.2.RELEASE:test
[INFO] |  +- org.springframework.boot:spring-boot-test-autoconfigure:jar:2.3.2.RELEASE:test
[INFO] |  +- org.junit.jupiter:junit-jupiter:jar:5.6.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-api:jar:5.6.2:test
[INFO] |  |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  |  \- org.junit.platform:junit-platform-commons:jar:1.6.2:test
[INFO] |  |  +- org.junit.jupiter:junit-jupiter-params:jar:5.6.2:test
[INFO] |  |  \- org.junit.jupiter:junit-jupiter-engine:jar:5.6.2:test
[INFO] |  +- org.junit.vintage:junit-vintage-engine:jar:5.6.2:test
[INFO] |  |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  |  \- org.junit.platform:junit-platform-engine:jar:1.6.2:test
[INFO] |  +- org.mockito:mockito-junit-jupiter:jar:3.3.3:test
[INFO] |  +- org.skyscreamer:jsonassert:jar:1.5.0:test
[INFO] |  |  \- com.vaadin.external.google:android-json:jar:0.0.20131108.vaadin1:test
[INFO] |  +- org.springframework:spring-test:jar:5.2.8.RELEASE:test
[INFO] |  \- org.xmlunit:xmlunit-core:jar:2.7.0:test
[INFO] +- org.powermock:powermock-module-junit4:jar:2.0.7:test
[INFO] |  +- org.powermock:powermock-module-junit4-common:jar:2.0.7:test
[INFO] |  |  +- org.powermock:powermock-reflect:jar:2.0.7:test
[INFO] |  |  \- org.powermock:powermock-core:jar:2.0.7:test
[INFO] |  |     \- org.javassist:javassist:jar:3.27.0-GA:test
[INFO] |  +- junit:junit:jar:4.13:compile
[INFO] |  \- org.hamcrest:hamcrest-core:jar:2.2:test
[INFO] +- org.powermock:powermock-api-mockito2:jar:2.0.7:test
[INFO] |  \- org.powermock:powermock-api-support:jar:2.0.7:test
[INFO] +- org.mockito:mockito-core:jar:2.23.0:test
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.10.13:test
[INFO] |  +- net.bytebuddy:byte-buddy-agent:jar:1.10.13:test
[INFO] |  \- org.objenesis:objenesis:jar:2.6:test Seems like you are using a version of PowerMock that is not compatible with the particular version of Mockito. Please check the PowerMock documentation to see what version to use and see if there's a compatible update. for my case,  after i added dependencies of spring-test, spring-tx, assertj-core. error does not appear any more. It is work for me.

```
androidTestImplementation("org.mockito:mockito-android:3.6.28")
androidTestImplementation("io.mockk:mockk-android:1.10.3") {
     exclude module: 'dexmaker'
}
// newer versions break Mockito
androidTestImplementation "com.linkedin.dexmaker:dexmaker:2.28.0"
``` We haven't received any new reports for almost a year, so I am closing this issue now. Thanks everyone for your contributions! If anybody else runs into this issue in the future, please double-check the version of ByteBuddy you are using and make sure it adheres to the dependency requirements that Mockito has.
I don't think this warrants a new minor release. I think this should be just 2.25.5 No probs. I generally like to publish new minor every few weeks. It's arbitrary what we warrant a new minor release, and that's OK.

I need to finally set up the automation that automatically pushes to MavenCentral if the version is next minor.
Unexpected error (Mockito can only mock non-private & non-final classes.) in version 2.24.0
Hi,

Since version 2.24.0 I got the error "Mockito can only mock non-private & non-final classes.". Reverting back to Mockito 2.23.4 resolves the problem.

**Stacktrace**
`Underlying exception : java.lang.IllegalArgumentException: Could not create type
	at nl.tkp.ddw.pensioenaangifte.test.model.unittesten.AanleveringFilteringStepDefinitions.setup(AanleveringFilteringStepDefinitions.java:43)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at cucumber.runtime.Utils$1.call(Utils.java:26)
	at cucumber.runtime.Timeout.timeout(Timeout.java:16)
	at cucumber.runtime.Utils.invoke(Utils.java:20)
	at cucumber.runtime.java.JavaHookDefinition.execute(JavaHookDefinition.java:60)
	at cucumber.runner.HookDefinitionMatch.runStep(HookDefinitionMatch.java:16)
	at cucumber.runner.TestStep.executeStep(TestStep.java:63)
	at cucumber.runner.TestStep.run(TestStep.java:49)
	at cucumber.runner.TestCase.run(TestCase.java:40)
	at cucumber.runner.Runner.runPickle(Runner.java:40)
	at cucumber.runtime.junit.PickleRunners$NoStepDescriptions.run(PickleRunners.java:146)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:68)
	at cucumber.runtime.junit.FeatureRunner.runChild(FeatureRunner.java:23)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at cucumber.runtime.junit.FeatureRunner.run(FeatureRunner.java:73)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:124)
	at cucumber.api.junit.Cucumber.runChild(Cucumber.java:65)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at cucumber.api.junit.Cucumber$1.evaluate(Cucumber.java:133)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:110)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
	at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
	at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:62)
	at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:51)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
	at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
	at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
	at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:118)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
	at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:175)
	at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:157)
	at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalArgumentException: Could not create type
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
	at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:32)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMockType(SubclassByteBuddyMockMaker.java:71)
	at org.mockito.internal.creation.bytebuddy.SubclassByteBuddyMockMaker.createMock(SubclassByteBuddyMockMaker.java:42)
	at org.mockito.internal.creation.bytebuddy.ByteBuddyMockMaker.createMock(ByteBuddyMockMaker.java:25)
	at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:35)
	at org.mockito.internal.MockitoCore.mock(MockitoCore.java:62)
	at org.mockito.Mockito.mock(Mockito.java:1896)
	at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:44)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:19)
	at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:16)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:38)
	at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:62)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:49)
	at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:41)
	at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:69)
	... 63 more
Caused by: java.lang.NoSuchMethodError: net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific(Ljava/util/Collection;)Lnet/bytebuddy/dynamic/loading/MultipleParentClassLoader$Builder;
	at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:83)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:37)
	at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator$1.call(TypeCachingBytecodeGenerator.java:34)
	at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
	... 81 more`

**Versioninfo**
Java: 1.8
JVM vendor name: Oracle Corporation
JVM vendor version: 25.191-b12
JVM name: Java HotSpot(TM) 64-Bit Server VM
JVM version: 1.8.0_191-b12
JVM info: mixed mode
OS name: Mac OS X
OS version: 10.13.6
Mockito-core: 2.24.0
gradle/dependencies.gradle
gradle/dependencies.gradle
diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle
index fe5509e557..c6462ed7e3 100644
--- a/gradle/dependencies.gradle
+++ b/gradle/dependencies.gradle
@@ -4,7 +4,7 @@ ext {
 
 def versions = [:]
 
-versions.bytebuddy = '1.9.7'
+versions.bytebuddy = '1.9.11'
 versions.junitJupiter = '5.1.1'
 versions.errorprone = '2.3.2'
 
