{"record":{"id":"f8103131f1774946","repo":"mockito/mockito","slug":"could-not-initialize-inline-byte-buddy-mock-maker","errorCode":null,"errorMessage":"Could not initialize inline Byte Buddy mock maker.\n\n<detail>\n<platformDescription>","messagePattern":"Could not initialize inline Byte Buddy mock maker\\.\n\n<detail>\n<platformDescription>","errorType":"exception","errorClass":"MockitoInitializationException","httpStatus":null,"severity":"error","filePath":"mockito-core/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java","lineNumber":278,"sourceCode":"                                        \"\",\n                                        \"Byte Buddy Agent is available on Maven Central as 'net.bytebuddy:byte-buddy-agent' with the module name 'net.bytebuddy.agent'.\",\n                                        \"Normally, your IDE or build tool (such as Maven or Gradle) should take care of your class path completion but \");\n                    } else if (Class.forName(\"javax.tools.ToolProvider\")\n                                    .getMethod(\"getSystemJavaCompiler\")\n                                    .invoke(null)\n                            == null) {\n                        detail =\n                                \"It appears as if you are running on a JRE. Either install a JDK or add JNA to the class path.\";\n                    } else {\n                        detail =\n                                \"It appears as if your JDK does not supply a working agent attachment mechanism.\";\n                    }\n                } catch (Throwable ignored) {\n                    detail =\n                            \"It appears as if you are running an incomplete JVM installation that might not support all tooling APIs\";\n                }\n            }\n            throw new MockitoInitializationException(\n                    join(\n                            \"Could not initialize inline Byte Buddy mock maker.\",\n                            \"\",\n                            detail,\n                            Platform.describe()),\n                    INITIALIZATION_ERROR);\n        }\n\n        ThreadLocal<Class<?>> currentConstruction = new ThreadLocal<>();\n        ThreadLocal<Boolean> isSuspended = ThreadLocal.withInitial(() -> false);\n        Predicate<Class<?>> isCallFromSubclassConstructor = StackWalkerChecker.orFallback();\n        Predicate<Class<?>> isMockConstruction =\n                type -> {\n                    if (isSuspended.get()) {\n                        return false;\n                    } else if ((currentMocking.get() != null\n                                    && type.isAssignableFrom(currentMocking.get()))\n                            || currentConstruction.get() != null) {","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/mockito/mockito/blob/5a676bcd9ef9a10db46e1dc34e190eb46faa2687/mockito-core/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java#L260-L296","documentation":"Catch-all IllegalStateException from the inline mock maker's constructor: instrumenting the JVM (attaching the Byte Buddy agent, resolving the dispatcher) failed, and the message is assembled from fallback hints (e.g. missing byte-buddy-agent on the class path, or no system Java compiler available to generate the agent) plus a Platform.describe() snapshot. It indicates the inline mock maker could not initialize on this VM, not that a specific mock was bad.","triggerScenarios":"Thrown at mockito-core/src/main/java/org/mockito/internal/creation/bytebuddy/InlineDelegateByteBuddyMockMaker.java:278 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the 'net.bytebuddy:byte-buddy-agent' dependency (module name 'net.bytebuddy.agent') matching your byte-buddy version","Start the JVM with '-javaagent:byte-buddy-agent.jar' so self-attach is not needed","Upgrade Mockito and Byte Buddy to versions supporting your JDK","If the runtime lacks the instrumentation API (e.g. some restricted JREs), switch to mockito-core's subclass mock maker via '--mock-maker subclass' or the mock-maker-subclass extension"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a676bcd9ef9a10db46e1dc34e190eb46faa2687","analyzedAt":"2026-09-05T19:32:58.607Z","contentChangedAt":"2026-09-05T19:32:58.607Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}