{"record":{"id":"de127718119d8358","repo":"openjdk/jdk","slug":"jvmti-error-illegal-argument","errorCode":"JVMTI_ERROR_ILLEGAL_ARGUMENT","errorMessage":"Illegal argument or not JAR file\\n","messagePattern":"Illegal argument or not JAR file\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java.instrument/share/native/libinstrument/InvocationAdapter.c","lineNumber":967,"sourceCode":"                }\n                parent = basePath(canonicalPath);\n                jplis_assert(parent != (char*)NULL);\n                haveBasePath = 1;\n            }\n\n            resolved = resolve(parent, path);\n            jvmtierr = (*jvmtienv)->AddToBootstrapClassLoaderSearch(jvmtienv, resolved);\n            free(resolved);\n        }\n\n        /* print warning if boot class path not updated */\n        if (jvmtierr != JVMTI_ERROR_NONE) {\n            check_phase_blob_ret(jvmtierr, free(path));\n\n            fprintf(stderr, \"WARNING: %s not added to bootstrap class loader search: \", path);\n            switch (jvmtierr) {\n                case JVMTI_ERROR_ILLEGAL_ARGUMENT :\n                    fprintf(stderr, \"Illegal argument or not JAR file\\n\");\n                    break;\n                default:\n                    fprintf(stderr, \"Unexpected error: %d\\n\", jvmtierr);\n            }\n        }\n\n        /* finished with the path */\n        free(path);\n    }\n\n\n    /* clean-up */\n    if (haveBasePath && parent != canonicalPath) {\n        free(parent);\n    }\n    free(paths);\n}\n","sourceCodeStart":949,"sourceCodeEnd":985,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/share/native/libinstrument/InvocationAdapter.c#L949-L985","documentation":"The reason suffix for the bootstrap-add warning: JVMTI AddToBootstrapClassLoaderSearch returned JVMTI_ERROR_ILLEGAL_ARGUMENT, which per the JVMTI spec means the path is not a JAR file (directories and class files are rejected; only jars are legal for the bootstrap search) or the argument was otherwise invalid.","triggerScenarios":"A Boot-Class-Path entry naming a directory, a .class file, a zip that is not a jar, or a path with a query/fragment component left untrimmed.","commonSituations":"Porting agents from the old -Xbootclasspath/a style (which accepted directories) to Boot-Class-Path manifests (jars only); build pipelines copying a classes/ directory where a jar is expected.","solutions":["Replace directory entries with a jar: jar cf extra.jar -C classes .","Point Boot-Class-Path only at .jar files","For directories, use -Xbootclasspath/a:dir at JVM launch instead of the manifest attribute"],"exampleFix":"# before\nBoot-Class-Path: classes/   # directory -> ILLEGAL_ARGUMENT\n# after\nBoot-Class-Path: extra-boot.jar","handlingStrategy":"validation","validationCode":"// jars only for bootstrap search\nif (!entry.endsWith(\".jar\") || !Files.isRegularFile(Path.of(entry)))\n    throw new IllegalArgumentException(\"bootstrap entries must be existing JAR files: \" + entry);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Remember AddToBootstrapClassLoaderSearch accepts jars only — package directories into a jar","Use -Xbootclasspath/a at launch when directories must appear on the boot path"],"tags":["java-instrument","boot-class-path","jvmti","jvm-only-jars","classpath"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}