openjdk/jdk · warning
Unexpected error: %d\n
Error message
Unexpected error: %d\n
What it means
Generic reason suffix for the bootstrap-add warning: AddToBootstrapClassLoaderSearch returned an unexpected JVMTI error code (number printed). Typical codes: 30 WRONG_PHASE (JVM past live phase), 109 OUT_OF_MEMORY, or internal errors. The entry is skipped and startup continues.
Source
Thrown at src/java.instrument/share/native/libinstrument/InvocationAdapter.c:970
haveBasePath = 1;
}
resolved = resolve(parent, path);
jvmtierr = (*jvmtienv)->AddToBootstrapClassLoaderSearch(jvmtienv, resolved);
free(resolved);
}
/* print warning if boot class path not updated */
if (jvmtierr != JVMTI_ERROR_NONE) {
check_phase_blob_ret(jvmtierr, free(path));
fprintf(stderr, "WARNING: %s not added to bootstrap class loader search: ", path);
switch (jvmtierr) {
case JVMTI_ERROR_ILLEGAL_ARGUMENT :
fprintf(stderr, "Illegal argument or not JAR file\n");
break;
default:
fprintf(stderr, "Unexpected error: %d\n", jvmtierr);
}
}
/* finished with the path */
free(path);
}
/* clean-up */
if (haveBasePath && parent != canonicalPath) {
free(parent);
}
free(paths);
}
View on GitHub (pinned to 88dfb74bbe)
Solutions
- Decode the number against the jvmtiError enum (e.g. 30=WRONG_PHASE, 109=OUT_OF_MEMORY) and address that condition
- Load the agent earlier (launch-time -javaagent) so boot path updates happen in the correct phase
- Free native memory / raise limits if OOM is indicated
- Retry the load once the JVM is stably in the live phase
Example fix
# before: attaching during shutdown vm.loadAgent(...); // WRONG_PHASE (30) # after: attach while app is running vm.loadAgent(...);
Defensive patterns
Strategy: fallback
Validate before calling
// check JVM liveness phase before attaching
if (vm instanceof VirtualMachine && Boolean.getBoolean("shutdown.in.progress"))
throw new IllegalStateException("refusing to attach during shutdown"); Prevention
- Attach during stable live phase; avoid shutdown hooks
- Decode unexpected JVMTI codes against the jvmtiError enum before retrying blindly
When it happens
Trigger: Boot-Class-Path processing occurring during JVM shutdown/wrong phase; native OOM; JVMTI internal failure.
Common situations: Agents attaching late in JVM lifetime; memory-pressured JVMs; rarely, JDK bugs.
Related errors
- Unexpected error (%d) returned by AddToSystemClassLoaderSear
- WARNING: %s not added to bootstrap class loader search:
- JVMTI_ERROR_ILLEGAL_ARGUMENT
- System class loader does not define the appendToClassPathFor
- WARNING: illegal character in Boot-Class-Path value: %s\n
AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14).
Data as JSON: /api/errors/fecfe643fe1efebe.
Report an issue: GitHub.