Better error message if mock-maker-inline is used on Android
See original GitHub issueThe “mock-maker-inline” is not available on Android, the error message can be optimized so the message “This mock maker is not supported on Android” stands on the first line of the exception.
Currently users must dig in the root cause of the IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker.
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker
at org.mockito.internal.configuration.plugins.PluginLoader$1.invoke(PluginLoader.java:66)
at com.sun.proxy.$Proxy8.isTypeMockable(Unknown Source)
at org.mockito.internal.util.MockUtil.typeMockabilityOf(MockUtil.java:29)
at org.mockito.internal.util.MockCreationValidator.validateType(MockCreationValidator.java:22)
at org.mockito.internal.creation.MockSettingsImpl.validatedSettings(MockSettingsImpl.java:168)
at org.mockito.internal.creation.MockSettingsImpl.confirm(MockSettingsImpl.java:162)
at org.mockito.internal.MockitoCore.mock(MockitoCore.java:64)
at org.mockito.Mockito.mock(Mockito.java:1693)
at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:33)
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)
at org.mockito.internal.junit.JUnitRule$1.evaluate(JUnitRule.java:42)
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:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeration@73ad2d6
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:101)
at org.mockito.internal.configuration.plugins.PluginLoader.loadPlugin(PluginLoader.java:45)
at org.mockito.internal.configuration.plugins.PluginRegistry.<init>(PluginRegistry.java:18)
at org.mockito.internal.configuration.plugins.Plugins.<clinit>(Plugins.java:17)
at org.mockito.internal.configuration.GlobalConfiguration.tryGetPluginAnnotationEngine(GlobalConfiguration.java:55)
at org.mockito.MockitoAnnotations.initMocks(MockitoAnnotations.java:68)
... 20 more
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker. (This mock maker is not supported on Android.)
Java : 1.8
JVM vendor name : Oracle Corporation
JVM vendor version : 25.76-b03
JVM name : OpenJDK 64-Bit Server VM
JVM version : 1.8.0_76-release-b03
JVM info : mixed mode
OS name : Windows 7
OS version : 6.1
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<init>(InlineByteBuddyMockMaker.java:172)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at java.lang.Class.newInstance(Class.java:442)
at org.mockito.internal.configuration.plugins.PluginLoader.loadImpl(PluginLoader.java:96)
... 25 more
Caused by: java.lang.IllegalStateException: Error during attachment using: net.bytebuddy.agent.ByteBuddyAgent$AttachmentProvider$Compound@23d4d935
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:316)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:282)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:250)
at net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:236)
at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.<clinit>(InlineByteBuddyMockMaker.java:102)
... 31 more
Caused by: java.lang.reflect.InvocationTargetException
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 net.bytebuddy.agent.ByteBuddyAgent.install(ByteBuddyAgent.java:303)
... 35 more
Caused by: com.sun.tools.attach.AttachNotSupportedException: no providers installed
at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208)
... 40 more
Issue Analytics
- State:
- Created 7 years ago
- Comments:22 (9 by maintainers)
Top Results From Across the Web
Mockito: mock-maker-inline Android GcmNetworkManager ...
This error indicates that the verifier, included in the Java Virtual Machine (JVM), detected a class file that despite well formed, it contains ......
Read more >InlineStaticMockMaker.java - Android Code Search
public final class InlineStaticMockMaker implements MockMaker { ... Error during one time init or {@code null} if init was successful.
Read more >Mockito 3.0.0 API - Javadoc.io
Be aware that you cannot use the inline mock maker on Android due to limitations in the Android VM. If you encounter issues...
Read more >Could not initialize inline Byte Buddy mock maker ... - YouTrack
(This mock maker is not supported on Android.) ... Unable to provision, see the following errors: 1) Error in custom ... 49 more...
Read more >How to use the Mockito's inline mock maker - David Vlijmincx
Write better tests by mocking the constructor, static methods, have stricter mocking, mock final classes/methods, and easy-to-use argument ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@raphw I wonder why I see this error at all, since I am running the test locally on a “normal” JVM+JRE not on the device or emulator?!
I ran into this issue after integrating Robolectric into my tests. Is anybody else who sees this error using Robolectric? Could help explain.