{"record":{"id":"e06989a205cdd7fc","repo":"pinpoint-apm/pinpoint","slug":"classreader-fail-classfile","errorCode":null,"errorMessage":"ClassReader fail, classFile=","messagePattern":"ClassReader fail, classFile=","errorType":"exception","errorClass":"InstrumentException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMInterceptorHolder.java","lineNumber":160,"sourceCode":"            final Class<?> mainClass = InterceptorDefineClassHelper.defineClass(classLoader, className, mainClassBytes);\n            final byte[] innerClassByte = toInnerClassByteArray();\n            InterceptorDefineClassHelper.defineClass(classLoader, innerClassName, innerClassByte);\n            return mainClass;\n        } catch (Exception e) {\n            throw new InstrumentException(\"defineClass fail\", e);\n        }\n    }\n\n    byte[] toMainClassByteArray() throws InstrumentException {\n        try {\n            ClassNode classNode = readClass(INTERCEPTOR_HOLDER_CLASS);\n            final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);\n            final ClassVisitor renameClassAdapter = new RenameClassAdapter(classWriter, className);\n            classNode.accept(renameClassAdapter);\n            return classWriter.toByteArray();\n        } catch (IOException e) {\n            // read fail\n            throw new InstrumentException(\"ClassReader fail, classFile=\" + INTERCEPTOR_HOLDER_CLASS, e);\n        }\n    }\n\n    byte[] toInnerClassByteArray() throws InstrumentException {\n        try {\n            ClassNode classNode = readClass(INTERCEPTOR_HOLDER_INNER_CLASS);\n            final ClassWriter classWriter = new ClassWriter(ClassWriter.COMPUTE_FRAMES);\n            final ClassVisitor renameClassAdapter = new RenameInnerClassAdapter(classWriter, className);\n            classNode.accept(renameClassAdapter);\n            return classWriter.toByteArray();\n        } catch (IOException e) {\n            // read fail\n            throw new InstrumentException(\"ClassReader fail, classFile=\" + INTERCEPTOR_HOLDER_INNER_CLASS, e);\n        }\n    }\n\n    ClassNode readClass(String classFileName) throws IOException {\n        final ClassLoader classLoader = ASMInterceptorHolder.class.getClassLoader();","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMInterceptorHolder.java#L142-L178","documentation":"toMainClassByteArray reads the bundled InterceptorHolder.class template from the profiler classloader and rewrites it with ASM. This InstrumentException wraps an IOException from readClass — either the template resource was not found on the classpath (InputStream null) or the class bytes failed to be parsed by ASM's ClassReader (corrupted resource).","triggerScenarios":"Calling toMainClassByteArray (via defineClass/build) when com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorHolder.class is absent from the agent classpath or its bytes are corrupt/incompatible with the bundled ASM ClassReader.","commonSituations":"Broken shading/relocation of the profiler jar by a downstream packager, an incomplete agent deployment, or mixing ASM versions so ClassReader rejects a newer class-file version.","solutions":["Verify the profiler jar contains InterceptorHolder.class at the exact package path (jar tf)","Re-download/re-extract the Pinpoint agent distribution to fix a corrupted jar","Check getCause(): 'not found class ...' means missing resource; a format error means ASM/JDK version mismatch","If shading the agent, keep the template resource and matching ASM dependency in the shaded artifact"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify template resource before generating bytes\nString tpl = \"com/navercorp/pinpoint/profiler/instrument/interceptor/InterceptorHolder.class\";\nif (ASMInterceptorHolder.class.getClassLoader().getResourceAsStream(tpl) == null) {\n    throw new IllegalStateException(\"missing profiler template resource: \" + tpl);\n}","typeGuard":null,"tryCatchPattern":"try {\n    holder.defineClass(classLoader);\n} catch (InstrumentException e) {\n    if (e.getCause() instanceof IOException) {\n        logger.error(\"template read failed — profiler jar corrupt or mis-shaded: {}\", e.getMessage());\n    }\n}","preventionTips":["Verify jar contents after build: jar tf | grep InterceptorHolder.class","Avoid relocation/shading that drops or renames template resources","Use full official agent distributions, not partially copied jars"],"tags":["asm","classpath","bytecode"],"backgroundTag":"file-not-found","analyzedSha":"744c3d3075e595656abb1ae331ad2c0e4c9eb996","analyzedAt":"2026-09-07T18:48:45.289Z","contentChangedAt":"2026-09-07T18:48:45.289Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}