{"record":{"id":"413af3a2a93d656f","repo":"pinpoint-apm/pinpoint","slug":"system-classloader-is-null","errorCode":null,"errorMessage":"system classloader is null.","messagePattern":"system classloader is null\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classreading/ClassReaderWrapper.java","lineNumber":81,"sourceCode":"        if (readAttributes) {\n            readAttributes();\n        }\n    }\n\n    public ClassReaderWrapper(final ClassLoader classLoader, final String classInternalName) throws IOException {\n        this(classLoader, classInternalName, false);\n    }\n\n    // classloader and class internal name.\n    public ClassReaderWrapper(final ClassLoader classLoader, final String classInternalName, final boolean readAttributes) throws IOException {\n        Objects.requireNonNull(classInternalName, \"classInternalName\");\n\n        ClassLoader cl = classLoader;\n        if (cl == null) {\n            cl = ClassLoader.getSystemClassLoader();\n            if (cl == null) {\n                // system fail.\n                throw new IOException(\"system classloader is null.\");\n            }\n        }\n\n        final String classPath = classInternalName.concat(\".class\");\n        final InputStream in = cl.getResourceAsStream(classPath);\n        if (in == null) {\n            throw new IOException(\"not found class. classLoader=\" + cl + \", classInternalName=\" + classInternalName);\n        }\n\n        byte[] bytes = IOUtils.toByteArray(in);\n        this.classReader = new ClassReader(bytes);\n        if (readAttributes) {\n            readAttributes();\n        }\n    }\n\n    // class's access flags.\n    public int getAccess() {","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/classreading/ClassReaderWrapper.java#L63-L99","documentation":"IOException thrown by ClassReaderWrapper when it needs a fallback classloader to read a class resource and ClassLoader.getSystemClassLoader() returns null. Pinpoint reads the class's bytecode via getResourceAsStream; without any usable classloader it cannot proceed.","triggerScenarios":"readClasspathClass/classReader initialization invoked with classLoader == null while running in an environment where the system classloader is unavailable (e.g. code running on the bootstrap classloader, some embedding/agent scenarios).","commonSituations":"Instrumentation of bootstrap classes where the target classloader is null and the JVM was started with -Xbootclasspath/a semantics making getSystemClassLoader() return null, or very unusual embedding setups that set the context loader to null.","solutions":["Pass an explicit non-null target ClassLoader to ClassReaderWrapper instead of relying on the null fallback.","Check JVM launch options that can suppress the system classloader for the instrumented code path.","If instrumenting bootstrap classes, use a classloader that can see the class (e.g. the one that triggered the transform)."],"exampleFix":"// before\nnew ClassReaderWrapper().readClassInternalName(internalName, null);\n// after\nnew ClassReaderWrapper().readClassInternalName(internalName, Thread.currentThread().getContextClassLoader());","handlingStrategy":"validation","validationCode":"ClassLoader cl = classLoader != null ? classLoader : ClassLoader.getSystemClassLoader();\nif (cl == null) throw new IllegalStateException(\"no usable classloader available to read \" + classInternalName);","typeGuard":null,"tryCatchPattern":"try { wrapper.readClassInternalName(name, cl); } catch (IOException e) { if (e.getMessage().contains(\"system classloader is null\")) { /* supply explicit loader or skip */ } throw e; }","preventionTips":["Always pass an explicit classloader when instrumenting bootstrap classes","Avoid running instrumentation code on the bootstrap classloader","Audit JVM flags that affect classloader hierarchy"],"tags":["classloading","classreader","pinpoint","bootstrap"],"backgroundTag":"system-classloader-null","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}