{"id":"b363577228b40b67","repo":"spring-projects/spring-framework","slug":"unsupported-advice-type-on-method","errorCode":null,"errorMessage":"Unsupported advice type on method: {}","messagePattern":"Unsupported advice type on method: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java","lineNumber":297,"sourceCode":"\t\t\tcase AtAfter -> springAdvice = new AspectJAfterAdvice(\n\t\t\t\t\tcandidateAdviceMethod, expressionPointcut, aspectInstanceFactory);\n\t\t\tcase AtAfterReturning -> {\n\t\t\t\tspringAdvice = new AspectJAfterReturningAdvice(\n\t\t\t\t\t\tcandidateAdviceMethod, expressionPointcut, aspectInstanceFactory);\n\t\t\t\tAfterReturning afterReturningAnnotation = (AfterReturning) aspectJAnnotation.getAnnotation();\n\t\t\t\tif (StringUtils.hasText(afterReturningAnnotation.returning())) {\n\t\t\t\t\tspringAdvice.setReturningName(afterReturningAnnotation.returning());\n\t\t\t\t}\n\t\t\t}\n\t\t\tcase AtAfterThrowing -> {\n\t\t\t\tspringAdvice = new AspectJAfterThrowingAdvice(\n\t\t\t\t\t\tcandidateAdviceMethod, expressionPointcut, aspectInstanceFactory);\n\t\t\t\tAfterThrowing afterThrowingAnnotation = (AfterThrowing) aspectJAnnotation.getAnnotation();\n\t\t\t\tif (StringUtils.hasText(afterThrowingAnnotation.throwing())) {\n\t\t\t\t\tspringAdvice.setThrowingName(afterThrowingAnnotation.throwing());\n\t\t\t\t}\n\t\t\t}\n\t\t\tdefault -> throw new UnsupportedOperationException(\n\t\t\t\t\t\"Unsupported advice type on method: \" + candidateAdviceMethod);\n\t\t}\n\n\t\t// Now to configure the advice...\n\t\tspringAdvice.setAspectName(aspectName);\n\t\tspringAdvice.setDeclarationOrder(declarationOrder);\n\t\t@Nullable String[] argNames = this.parameterNameDiscoverer.getParameterNames(candidateAdviceMethod);\n\t\tif (argNames != null) {\n\t\t\tspringAdvice.setArgumentNamesFromStringArray(argNames);\n\t\t}\n\t\tspringAdvice.calculateArgumentBindings();\n\n\t\treturn springAdvice;\n\t}\n\n\n\t/**\n\t * Synthetic advisor that instantiates the aspect.","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java#L279-L315","documentation":"Thrown by ReflectiveAspectJAdvisorFactory.getAdvice() in the default branch of the switch over AspectJAnnotationType. Because findAspectJAnnotationOnMethod only returns a non-null AspectJAnnotation for the six known types (AtPointcut, AtAround, AtBefore, AtAfter, AtAfterReturning, AtAfterThrowing), all of which have explicit cases, this branch is effectively unreachable under normal operation. Reaching it indicates an internal inconsistency in the annotation-type mapping.","triggerScenarios":"Not reachable through public API in an unmodified Spring distribution. Would require a mismatch between ASPECTJ_ANNOTATION_CLASSES and the AspectJAnnotationType enum / switch cases (e.g. a fork adding a new annotation type without a switch case).","commonSituations":"Not encountered in standard use. Theoretically a fork/extension problem. Could appear with a corrupted aspectjweaver that misreports annotation types.","solutions":["Verify spring-aop and aspectjweaver versions are matched and unmodified.","If forking Spring, add a switch case for every new AspectJAnnotationType value.","Report as a Spring Framework bug with the full stack trace."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  factory.getAdvice(method, pointcut, instanceFactory, order, name);\n} catch (UnsupportedOperationException ex) {\n  if (ex.getMessage().startsWith(\"Unsupported advice type\")) {\n    // internal inconsistency — check spring-aop / aspectjweaver versions\n    throw new IllegalStateException(\"Possible Spring/AspectJ version mismatch\", ex);\n  }\n  throw ex;\n}","preventionTips":["Keep spring-aop and aspectjweaver versions matched and official.","Treat UnsupportedOperationException from internal switches as a version-mismatch signal."],"tags":["spring-aop","aspectj","internal","advice"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}