{"record":{"id":"cd0ae577b4b921b2","repo":"pinpoint-apm/pinpoint","slug":"invalid-class-hierarchy-source-class-sourceclas","errorCode":null,"errorMessage":"invalid class hierarchy. source class=${sourceClassInternalName}, advice class=${adviceClassInternalName}, super class=${superClassInternalName}","messagePattern":"invalid class hierarchy\\. source class=(.+?), advice class=(.+?), super class=(.+?)","errorType":"exception","errorClass":"InstrumentException","httpStatus":null,"severity":"error","filePath":"agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMAspectWeaver.java","lineNumber":65,"sourceCode":"    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        }\n\n        // find annotation methods and copy utility methods.\n        final MethodNodes methodNodes = findMethodNodes(adviceClassNode);\n\n        copyUtilMethods(methodNodes, sourceClassNode);\n        copyPointCutMethods(methodNodes, sourceClassNode);\n    }\n\n    private MethodNodes findMethodNodes(final ASMClassNodeAdapter adviceClassNode) {\n        final MethodNodes methodNodes = new MethodNodes();\n        for (ASMMethodNodeAdapter methodNode : adviceClassNode.getDeclaredMethods()) {\n            if (methodNode.hasAnnotation(PointCut.class)) {\n                methodNodes.pointCuts.add(methodNode);\n                continue;\n            }\n            if (methodNode.hasAnnotation(JointPoint.class)) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/pinpoint-apm/pinpoint/blob/744c3d3075e595656abb1ae331ad2c0e4c9eb996/agent-module/profiler/src/main/java/com/navercorp/pinpoint/profiler/instrument/ASMAspectWeaver.java#L47-L83","documentation":"After checking the @Aspect annotation, weaving() validates the class hierarchy: the advice class must be a subclass of the source class, or its superclass must be java/lang/Object. Otherwise the weaved code would be invalid, so InstrumentException is thrown with source, advice, and superclass internal names.","triggerScenarios":"Weaving when adviceClassNode is neither a subclass of the source class nor a direct child of Object — e.g. advice extends a different base class than the target.","commonSituations":"Advice class written against an older version of the target class; the target's hierarchy changed and the advice no longer extends it; or source/advice class pair mixed up in the call.","solutions":["Make the advice class extend the source class (or java/lang/Object)","Ensure you pass source and advice class nodes in the correct order to weaving()","Regenerate the advice class after a target class hierarchy change","Verify superclass internal names match the expected hierarchy"],"exampleFix":"// before\npublic class MyAdvice extends SomeOtherBase { ... }\n// after\npublic class MyAdvice extends TargetClass { ... }","handlingStrategy":"validation","validationCode":"boolean ok = adviceClassNode.subclassOf(sourceClassNode.getInternalName()) || \"java/lang/Object\".equals(adviceClassNode.getSuperClassInternalName());","typeGuard":null,"tryCatchPattern":"try { weaver.weaving(src, adv); } catch (InstrumentException e) { logger.error(\"hierarchy invalid: {}\", e.getMessage()); }","preventionTips":["Keep advice extending the source class (or Object)","Regenerate advice after target hierarchy changes","Double-check argument order (source, advice) in weaving()"],"tags":["java","bytecode","asm","class-hierarchy"],"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-14T05:17:10.506Z"}