{"record":{"id":"8ffad8a15b3bdbba","repo":"pinpoint-apm/pinpoint","slug":"not-bootstrapclassloader","errorCode":null,"errorMessage":"not BootStrapClassLoader","messagePattern":"not BootStrapClassLoader","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/BootstrapClassLoaderHandler.java","lineNumber":51,"sourceCode":"\n    private final Logger logger = LogManager.getLogger(this.getClass());\n\n    private final PluginConfig pluginConfig;\n    private final InstrumentEngine instrumentEngine;\n\n    private final Object lock = new Object();\n    private volatile boolean injectedToRoot = false;\n\n    public BootstrapClassLoaderHandler(PluginConfig pluginConfig, InstrumentEngine instrumentEngine) {\n        this.pluginConfig = Objects.requireNonNull(pluginConfig, \"pluginConfig\");\n        this.instrumentEngine = Objects.requireNonNull(instrumentEngine, \"instrumentEngine\");\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public <T> Class<? extends T> injectClass(ClassLoader classLoader, String className) {\n        if (classLoader != Object.class.getClassLoader()) {\n            throw new IllegalStateException(\"not BootStrapClassLoader\");\n        }\n        try {\n            return (Class<T>) injectClass0(className);\n        } catch (Exception e) {\n            logger.warn(\"Failed to load plugin class {} with classLoader {}\", className, classLoader, e);\n            throw new PinpointException(\"Failed to load plugin class \" + className + \" with classLoader \" + classLoader, e);\n        }\n    }\n\n    private Class<?> injectClass0(String className) throws IllegalArgumentException, ClassNotFoundException {\n        appendToBootstrapClassLoaderSearch();\n        return Class.forName(className, false, null);\n    }\n\n    private void appendToBootstrapClassLoaderSearch() {\n        // DCL\n        if (injectedToRoot) {\n            return;","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classloading/BootstrapClassLoaderHandler.java#L33-L69","documentation":"IllegalStateException thrown by BootstrapClassLoaderHandler.injectClass when the passed class loader is not the bootstrap class loader (represented by Object.class.getClassLoader() == null). This handler only serves classes that must be injected into the bootstrap class loader; any other class loader is a programming error by the caller.","triggerScenarios":"Calling injectClass with an application or plugin class loader instead of null (bootstrap); the class loader routing logic in the instrumentation engine dispatching to the wrong handler for a class expected to be bootstrap-loaded.","commonSituations":"Plugin code manually calling ClassInjector variants with the wrong loader; a target class mistakenly detected as a bootstrap class; custom engine wiring dispatching helper classes to the bootstrap handler.","solutions":["Ensure this handler is only invoked for classes marked for bootstrap injection (loader == null)","Route non-bootstrap classes to the appropriate ClassInjector (plugin/ProfilerClassLoader handler)","Fix the class loader detection logic that selected the bootstrap handler for this class"],"exampleFix":"// before\ninjector.injectClass(targetClassLoader, \"com.bootstrap.Helper\");\n// after\nif (targetClassLoader == null) {\n    injector.injectClass(targetClassLoader, \"com.bootstrap.Helper\");\n} else {\n    pluginInjector.injectClass(targetClassLoader, \"com.plugin.Helper\");\n}","handlingStrategy":"type-guard","validationCode":"if (classLoader != null) {\n    throw new IllegalArgumentException(\"bootstrap injector requires null classLoader\");\n}","typeGuard":"boolean isBootstrapClassLoader(ClassLoader cl) {\n    return cl == Object.class.getClassLoader(); // null\n}","tryCatchPattern":"try {\n    return handler.injectClass(classLoader, className);\n} catch (IllegalStateException e) {\n    if (\"not BootStrapClassLoader\".equals(e.getMessage())) {\n        return pluginHandler.injectClass(classLoader, className);\n    }\n    throw e;\n}","preventionTips":["Dispatch class injection by class-loader type before choosing a handler","Never pass an application loader to the bootstrap handler","Centralize loader routing in one injector facade"],"tags":["classloader","bootstrap","instrumentation"],"backgroundTag":"invalid-argument-value","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}