{"id":"8b8cf01c20e3b646","repo":"spring-projects/spring-framework","slug":"number-of-pointcut-parameter-names-must-match-numb","errorCode":null,"errorMessage":"Number of pointcut parameter names must match number of pointcut parameter types","messagePattern":"Number of pointcut parameter names must match number of pointcut parameter types","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java","lineNumber":134,"sourceCode":"\tprivate transient volatile boolean pointcutParsingFailed;\n\n\n\t/**\n\t * Create a new default AspectJExpressionPointcut.\n\t */\n\tpublic AspectJExpressionPointcut() {\n\t}\n\n\t/**\n\t * Create a new AspectJExpressionPointcut with the given settings.\n\t * @param declarationScope the declaration scope for the pointcut\n\t * @param paramNames the parameter names for the pointcut\n\t * @param paramTypes the parameter types for the pointcut\n\t */\n\tpublic AspectJExpressionPointcut(Class<?> declarationScope, String[] paramNames, Class<?>[] paramTypes) {\n\t\tsetPointcutDeclarationScope(declarationScope);\n\t\tif (paramNames.length != paramTypes.length) {\n\t\t\tthrow new IllegalStateException(\n\t\t\t\t\t\"Number of pointcut parameter names must match number of pointcut parameter types\");\n\t\t}\n\t\tthis.pointcutParameterNames = paramNames;\n\t\tthis.pointcutParameterTypes = paramTypes;\n\t}\n\n\n\t/**\n\t * Set the declaration scope for the pointcut.\n\t */\n\tpublic void setPointcutDeclarationScope(Class<?> pointcutDeclarationScope) {\n\t\tthis.pointcutDeclarationScope = pointcutDeclarationScope;\n\t\tthis.aspectCompiledByAjc = compiledByAjc(pointcutDeclarationScope);\n\t}\n\n\t/**\n\t * Set the parameter names for the pointcut.\n\t */","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/AspectJExpressionPointcut.java#L116-L152","documentation":"Thrown by the AspectJExpressionPointcut constructor when the paramNames and paramTypes arrays have different lengths. A pointcut expression that references bound parameters requires a one-to-one correspondence between names and types; mismatched arrays are a programming error.","triggerScenarios":"Constructing an AspectJExpressionPointcut directly with new AspectJExpressionPointcut(scope, names, types) where names.length != types.length.","commonSituations":"Programmatic pointcut construction (not via XML/annotation config) where the caller assembles the two arrays separately and they drift out of sync; refactoring that adds a type but forgets the name or vice versa.","solutions":["Ensure paramNames.length == paramTypes.length before constructing.","Build both arrays from a single source of truth (e.g. a list of parameter descriptors).","Prefer setParameterNames/setParameterTypes with consistent data."],"exampleFix":"// before\nnew AspectJExpressionPointcut(scope, new String[]{\"a\"}, new Class[]{int.class, String.class});\n\n// after\nnew AspectJExpressionPointcut(scope, new String[]{\"a\", \"b\"}, new Class[]{int.class, String.class});","handlingStrategy":"validation","validationCode":"if (paramNames.length != paramTypes.length) {\n    throw new IllegalArgumentException(\"paramNames and paramTypes length mismatch\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Derive paramNames and paramTypes from a single parameter-descriptor list.","Add an assertion before constructing the pointcut.","Prefer setParameterNames/setParameterTypes fed from the same source."],"tags":["spring-aop","aspectj","pointcut","configuration"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}