{"record":{"id":"8cf9da24182c3d92","repo":"pinpoint-apm/pinpoint","slug":"source-and-advice-class-node-must-not-be-null","errorCode":null,"errorMessage":"source and advice class node must not be null.","messagePattern":"source and advice class node must not be null\\.","errorType":"exception","errorClass":"InstrumentException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMAspectWeaver.java","lineNumber":49,"sourceCode":" */\npublic class ASMAspectWeaver {\n\n    private static final MethodNameReplacer DEFAULT_METHOD_NAME_REPLACER = new DefaultMethodNameReplacer();\n\n    private final Logger logger = LogManager.getLogger(this.getClass());\n    private final MethodNameReplacer methodNameReplacer;\n\n    public ASMAspectWeaver() {\n        this(DEFAULT_METHOD_NAME_REPLACER);\n    }\n\n    public ASMAspectWeaver(final MethodNameReplacer methodNameReplacer) {\n        this.methodNameReplacer = methodNameReplacer;\n    }\n\n    public void weaving(final ASMClassNodeAdapter sourceClassNode, final ASMClassNodeAdapter adviceClassNode) throws InstrumentException {\n        if (sourceClassNode == null || adviceClassNode == null) {\n            throw new InstrumentException(\"source and advice class node must not be null.\");\n        }\n\n        if (logger.isInfoEnabled()) {\n            logger.info(\"weaving sourceClass={} adviceClass={}\", sourceClassNode.getInternalName(), adviceClassNode.getInternalName());\n        }\n\n        if (!adviceClassNode.hasAnnotation(Aspect.class)) {\n            throw new InstrumentException(\"@Aspect not found. adviceClass=\" + adviceClassNode.getInternalName());\n        }\n\n        // advice class hierarchy check.\n        final boolean isSubclass = adviceClassNode.subclassOf(sourceClassNode.getInternalName());\n        if (!isSubclass) {\n            final String superClassInternalName = adviceClassNode.getSuperClassInternalName();\n            if (superClassInternalName == null || !superClassInternalName.equals(\"java/lang/Object\")) {\n                throw new InstrumentException(\"invalid class hierarchy. source class=\" + sourceClassNode.getInternalName() + \", advice class=\" + adviceClassNode.getInternalName() + \", super class=\" + superClassInternalName);\n            }\n        }","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMAspectWeaver.java#L31-L67","documentation":"ASMAspectWeaver.weaving() validates its two required class node arguments before weaving an advice class into a source class. If either the source class node or the advice class node is null it throws InstrumentException, since weaving cannot proceed without both bytecode representations.","triggerScenarios":"Calling weaving(sourceClassNode, adviceClassNode) with a null argument — usually when a class adapter failed to load/parse the bytecode and returned null instead of throwing.","commonSituations":"Aspect weaving during agent bootstrap where the advice class could not be read from the classpath, or a plugin passes a null node after a failed ASM parse.","solutions":["Check both arguments for null before calling weaving()","Verify the advice class exists on the agent/plugin classpath","Confirm the source class was successfully parsed by ASMClassNodeAdapter before weaving","Log the class name that failed to load to identify the missing bytecode"],"exampleFix":"// before\nweaver.weaving(sourceNode, adviceNode);\n// after\nif (sourceNode == null || adviceNode == null) {\n    throw new IllegalStateException(\"cannot weave: source=\" + sourceNode + \" advice=\" + adviceNode);\n}\nweaver.weaving(sourceNode, adviceNode);","handlingStrategy":"validation","validationCode":"if (sourceClassNode == null || adviceClassNode == null) { throw new IllegalArgumentException(\"both class nodes required\"); }","typeGuard":"boolean canWeave = sourceClassNode != null && adviceClassNode != null;","tryCatchPattern":"try { weaver.weaving(src, adv); } catch (InstrumentException e) { logger.error(\"weaving failed: {}\", e.getMessage()); }","preventionTips":["Verify class loading succeeded before weaving","Null-check adapter results","Log which class failed to parse"],"tags":["java","bytecode","asm","instrumentation"],"backgroundTag":"null-argument","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"}