{"record":{"id":"679bbfea68709ff1","repo":"spring-projects/spring-framework","slug":"unsupported-advice-type-on-method-candidateadvic","errorCode":null,"errorMessage":"Unsupported advice type on method: {candidateAdviceMethod}","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/69bf83ad716d0cfc4b0520a19b4d8b24c79d1538/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/ReflectiveAspectJAdvisorFactory.java#L279-L315","documentation":"Thrown as an UnsupportedOperationException from ReflectiveAspectJAdvisorFactory.getAdvice() in the switch default branch when the AspectJAnnotation's type is not AtPointcut, AtAround, AtBefore, AtAfter, AtAfterReturning, or AtAfterThrowing. Because findAspectJAnnotationOnMethod only produces annotations of those six types and AtPointcut returns null earlier, reaching this default is effectively unreachable through normal API usage, indicating an internal/state corruption.","triggerScenarios":"Internal: the AspectJAnnotation was constructed with a type not present in the switch; a future AspectJ annotation type added without updating the switch; reflective/test manipulation of the AspectJAnnotation type field. Not reachable via standard Spring AOP configuration.","commonSituations":"Library extensions that tamper with AspectJAnnotation; an AspectJ/Spring version skew introducing a new advice annotation type; corrupted/advisory state in tests.","solutions":["If encountered, collect the aspectJAdviceMethod and aspectJAnnotation details and report it as a Spring bug (it should be unreachable).","Ensure you are using mutually compatible versions of Spring AOP and AspectJ.","Avoid reflecting into or constructing AspectJAnnotation with non-standard types."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Unreachable via normal API; defense = keep Spring AOP and AspectJ versions compatible and\n// do not construct AspectJAnnotation with non-standard types.\nimport org.aspectj.lang.annotation.*;\nimport java.util.Set;\n\npublic static boolean isSwitchHandledAdviceAnnotation(Class<? extends java.lang.annotation.Annotation> t) {\n    return Set.of(Around.class, Before.class, After.class,\n                  AfterReturning.class, AfterThrowing.class).contains(t); // AtPointcut returns null earlier\n}\n","typeGuard":null,"tryCatchPattern":"try {\n    Advice advice = advisorFactory.getAdvice(method, pointcut, factory, order, name);\n} catch (UnsupportedOperationException ex) {\n    if (ex.getMessage().startsWith(\"Unsupported advice type\")) {\n        // should be unreachable; capture method + annotation and report upstream\n    } else throw ex;\n}","preventionTips":["Use compatible Spring + AspectJ versions.","Do not reflectively manipulate AspectJAnnotation internals.","Treat this exception as a defect to report, not a configuration issue."],"tags":["spring-aop","aspectj","internal","unreachable"],"backgroundTag":null,"analyzedSha":"69bf83ad716d0cfc4b0520a19b4d8b24c79d1538","analyzedAt":"2026-08-09T15:32:58.770Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}