{"record":{"id":"ba3f6229c8fa061a","repo":"openjdk/jdk","slug":"java-lang-instrument-javaagent-initialization-of","errorCode":null,"errorMessage":"java.lang.instrument/-javaagent: initialization of native agent failed.\\n","messagePattern":"java\\.lang\\.instrument/-javaagent: initialization of native agent failed\\.\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/java.instrument/share/native/libinstrument/InvocationAdapter.c","lineNumber":273,"sourceCode":"        free(premainClass);\n    }\n\n    if (initerror != JPLIS_INIT_ERROR_NONE) {\n        free(jarfile);\n    }\n    if (options != NULL) free(options);\n\n    switch (initerror) {\n    case JPLIS_INIT_ERROR_NONE:\n      result = JNI_OK;\n      break;\n    case JPLIS_INIT_ERROR_CANNOT_CREATE_NATIVE_AGENT:\n      result = JNI_ERR;\n      fprintf(stderr, \"java.lang.instrument/-javaagent: cannot create native agent.\\n\");\n      break;\n    case JPLIS_INIT_ERROR_FAILURE:\n      result = JNI_ERR;\n      fprintf(stderr, \"java.lang.instrument/-javaagent: initialization of native agent failed.\\n\");\n      break;\n    case JPLIS_INIT_ERROR_ALLOCATION_FAILURE:\n      result = JNI_ERR;\n      fprintf(stderr, \"java.lang.instrument/-javaagent: allocation failure.\\n\");\n      break;\n    case JPLIS_INIT_ERROR_AGENT_CLASS_NOT_SPECIFIED:\n      result = JNI_ERR;\n      fprintf(stderr, \"-javaagent: agent class not specified.\\n\");\n      break;\n    default:\n      result = JNI_ERR;\n      fprintf(stderr, \"java.lang.instrument/-javaagent: unknown error\\n\");\n      break;\n    }\n    return result;\n}\n\n/*","sourceCodeStart":255,"sourceCodeEnd":291,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/share/native/libinstrument/InvocationAdapter.c#L255-L291","documentation":"createNewJPLISAgent() returned the generic JPLIS_INIT_ERROR_FAILURE — native agent initialization failed for a reason other than allocation or agent-class absence (those have their own messages). The launcher prints this line and returns JNI_ERR, aborting startup. The specific native cause happened inside JPLIS initialization (e.g. setting up the transform/JNI machinery) and is only visible with native debugging.","triggerScenarios":"A later phase of -javaagent initialization failing: JNI environment setup, capability registration (Can-Retransform-Classes processing), or internal state transitions returning failure. Typically surfaces with unusual JVM configurations, broken JNI environments in embedded launchers, or JDK/libinstrument version mismatches (e.g. a launcher from one JDK invoking another release's JVM with agent options).","commonSituations":"Mixed-JDK tooling where the java launcher and the runtime libinstrument differ; JNI-embedded JVMs passing agent options; corrupted JDK installs (truncated/mismatched libs); OS-level interference (antivirus hooking, SELinux denials on the instrument library).","solutions":["Verify the JDK installation is intact and single-version: reinstall the JDK and ensure JAVA_HOME/PATH point at it","If embedding the JVM, verify you invoke with matching JNI libraries and a properly created VM before agent options are processed","Check OS logs (SELinux/auditd, antivirus) for denials against libinstrument.so / jvm.dll","Try the same agent on a stock launcher of the exact same JDK version to isolate embedding/tooling issues"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep launcher, JVM and libraries from one JDK distribution — no mixing versions","Verify JDK install integrity (checksums/reinstall) when this appears","Check SELinux/antivirus exclusions for the JDK's native libraries"],"tags":["javaagent","instrumentation","jvm-startup","initialization","native"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}