{"id":"7ac77638db9d8609","repo":"spring-projects/spring-framework","slug":"uses-percflowbelow-instantiation-model-this-is","errorCode":null,"errorMessage":"{} uses percflowbelow instantiation model: This is not supported in Spring AOP.","messagePattern":"(.+?) uses percflowbelow instantiation model: This is not supported in Spring AOP\\.","errorType":"exception","errorClass":"AopConfigException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java","lineNumber":104,"sourceCode":"\n\t@Override\n\tpublic boolean isAspect(Class<?> clazz) {\n\t\treturn (AnnotationUtils.findAnnotation(clazz, Aspect.class) != null &&\n\t\t\t\t(!shouldIgnoreAjcCompiledAspects || !compiledByAjc(clazz)));\n\t}\n\n\t@Override\n\tpublic void validate(Class<?> aspectClass) throws AopConfigException {\n\t\tAjType<?> ajType = AjTypeSystem.getAjType(aspectClass);\n\t\tif (!ajType.isAspect()) {\n\t\t\tthrow new NotAnAtAspectException(aspectClass);\n\t\t}\n\t\tif (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOW) {\n\t\t\tthrow new AopConfigException(aspectClass.getName() + \" uses percflow instantiation model: \" +\n\t\t\t\t\t\"This is not supported in Spring AOP.\");\n\t\t}\n\t\tif (ajType.getPerClause().getKind() == PerClauseKind.PERCFLOWBELOW) {\n\t\t\tthrow new AopConfigException(aspectClass.getName() + \" uses percflowbelow instantiation model: \" +\n\t\t\t\t\t\"This is not supported in Spring AOP.\");\n\t\t}\n\t}\n\n\n\t/**\n\t * Find and return the first AspectJ annotation on the given method\n\t * (there <i>should</i> only be one anyway...).\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\tprotected static @Nullable AspectJAnnotation findAspectJAnnotationOnMethod(Method method) {\n\t\tfor (Class<?> annotationType : ASPECTJ_ANNOTATION_CLASSES) {\n\t\t\tAspectJAnnotation annotation = findAnnotation(method, (Class<Annotation>) annotationType);\n\t\t\tif (annotation != null) {\n\t\t\t\treturn annotation;\n\t\t\t}\n\t\t}\n\t\treturn null;","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java#L86-L122","documentation":"Thrown by AbstractAspectJAdvisorFactory.validate() when an @AspectJ aspect declares the 'percflowbelow' instantiation model. Like percflow, this requires AspectJ's control-flow weaving machinery that Spring's runtime proxy-based AOP cannot provide. Spring AOP only supports the singleton per-clause (plus pertarget/perthis/pertypewithin with limitations).","triggerScenarios":"Any code path invoking validate(Class) on a class annotated @Aspect(\"percflowbelow(execution(* com.acme..*(..)))\") — e.g. AspectJProxyFactory.addAspect(Class) or auto-proxy creator processing.","commonSituations":"Porting a full AspectJ aspect into Spring AOP; declaring percflowbelow expecting Spring to honor it under @EnableAspectJAutoProxy.","solutions":["Drop the 'percflowbelow(...)' per-clause so the aspect defaults to singleton instantiation.","Use AspectJ compile-time or load-time weaving if percflowbelow semantics are required.","Approximate with a standard pointcut expression that excludes the aspect's own join points."],"exampleFix":"// before\n@Aspect(\"percflowbelow(execution(* com.acme..*(..)))\")\npublic class AuditAspect { ... }\n// after\n@Aspect\npublic class AuditAspect { ... }","handlingStrategy":"validation","validationCode":"import org.aspectj.lang.reflect.*;\n\nvoid checkNotPercflowbelow(Class<?> c) {\n  PerClauseKind k = AjTypeSystem.getAjType(c).getPerClause().getKind();\n  if (k == PerClauseKind.PERCFLOWBELOW)\n    throw new IllegalStateException(c + \" uses percflowbelow, unsupported by Spring AOP\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat percflow and percflowbelow as compile-time-weaving-only features.","Document supported per-clauses in your team's aspect guidelines (singleton only for Spring AOP)."],"tags":["spring-aop","aspectj","instantiation-model","configuration"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}