{"record":{"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/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/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. Each pointcut parameter requires both a name and a type, and they must correspond positionally; mismatched lengths are a configuration bug.","triggerScenarios":"Calling new AspectJExpressionPointcut(scope, new String[]{\"a\",\"b\"}, new Class<?>[]{String.class}) — 2 names but 1 type.","commonSituations":"Programmatic pointcut construction with buggy array initialization, or copy-paste errors when building parameter arrays.","solutions":["Ensure paramNames.length == paramTypes.length before constructing the pointcut","Use setParameterNames() and setParameterTypes() separately with carefully built arrays","Build the name and type arrays together from a single source (e.g., a list of param descriptors)"],"exampleFix":"// before\nnew AspectJExpressionPointcut(scope,\n    new String[]{\"a\", \"b\"},\n    new Class<?>[]{String.class}); // 2 names, 1 type\n\n// after\nnew AspectJExpressionPointcut(scope,\n    new String[]{\"a\", \"b\"},\n    new Class<?>[]{String.class, Integer.class});","handlingStrategy":"validation","validationCode":"// Validate array lengths match before constructing the pointcut\nif (paramNames.length != paramTypes.length) {\n    throw new IllegalArgumentException(\n        \"paramNames length (\" + paramNames.length + \") != paramTypes length (\" + paramTypes.length + \")\");\n}\nAspectJExpressionPointcut pc = new AspectJExpressionPointcut(scope, paramNames, paramTypes);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build paramNames and paramTypes from a single list of descriptors so they cannot diverge","Prefer setParameterNames()/setParameterTypes() from a single validated source"],"tags":["spring-aop","aspectj","pointcut","configuration"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}