{"id":"49e09a803fa47c33","repo":"spring-projects/spring-framework","slug":"unknown-annotation-type","errorCode":null,"errorMessage":"Unknown annotation type: {}","messagePattern":"Unknown annotation type: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java","lineNumber":198,"sourceCode":"\t\tpublic AspectJAnnotation(Annotation annotation) {\n\t\t\tthis.annotation = annotation;\n\t\t\tthis.annotationType = determineAnnotationType(annotation);\n\t\t\ttry {\n\t\t\t\tthis.pointcutExpression = resolvePointcutExpression(annotation);\n\t\t\t\tObject argNames = AnnotationUtils.getValue(annotation, \"argNames\");\n\t\t\t\tthis.argumentNames = (argNames instanceof String names ? names : \"\");\n\t\t\t}\n\t\t\tcatch (Exception ex) {\n\t\t\t\tthrow new IllegalArgumentException(annotation + \" is not a valid AspectJ annotation\", ex);\n\t\t\t}\n\t\t}\n\n\t\tprivate AspectJAnnotationType determineAnnotationType(Annotation annotation) {\n\t\t\tAspectJAnnotationType type = annotationTypeMap.get(annotation.annotationType());\n\t\t\tif (type != null) {\n\t\t\t\treturn type;\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Unknown annotation type: \" + annotation);\n\t\t}\n\n\t\tprivate String resolvePointcutExpression(Annotation annotation) {\n\t\t\tfor (String attributeName : EXPRESSION_ATTRIBUTES) {\n\t\t\t\tObject val = AnnotationUtils.getValue(annotation, attributeName);\n\t\t\t\tif (val instanceof String str && !str.isEmpty()) {\n\t\t\t\t\treturn str;\n\t\t\t\t}\n\t\t\t}\n\t\t\tthrow new IllegalStateException(\"Failed to resolve pointcut expression in: \" + annotation);\n\t\t}\n\n\t\tpublic AspectJAnnotationType getAnnotationType() {\n\t\t\treturn this.annotationType;\n\t\t}\n\n\t\tpublic Annotation getAnnotation() {\n\t\t\treturn this.annotation;","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/spring-projects/spring-framework/blob/e8729d043887bf0d0baf91e062e909b56eb2b708/spring-aop/src/main/java/org/springframework/aop/aspectj/annotation/AbstractAspectJAdvisorFactory.java#L180-L216","documentation":"Thrown by AspectJAnnotation.determineAnnotationType() when the annotation instance's type is not one of the six known AspectJ advice/pointcut annotations (Pointcut, Around, Before, After, AfterReturning, AfterThrowing). Because findAspectJAnnotationOnMethod only constructs AspectJAnnotation for annotations of those exact types, reaching this branch indicates an internal inconsistency — the annotation type map lacks an entry for a type that slipped through.","triggerScenarios":"This is effectively an internal/unreachable error: findAspectJAnnotationOnMethod iterates only over ASPECTJ_ANNOTATION_CLASSES, so annotationTypeMap should always contain a mapping. It would only fire if the map was extended or the annotation lookup returned a wrapper/meta-annotation not in the map.","commonSituations":"Not encountered under normal use. Theoretically reachable via a forked Spring version that adds an annotation to ASPECTJ_ANNOTATION_CLASSES without updating annotationTypeMap, or via a corrupted aspectjweaver.","solutions":["Verify you are using an unmodified, version-matched spring-aop and aspectjweaver pair.","If forking Spring, ensure annotationTypeMap has an entry for every class in ASPECTJ_ANNOTATION_CLASSES.","File a Spring Framework bug with the full stack trace and annotation details."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  factory.getAdvisors(instanceFactory);\n} catch (IllegalStateException ex) {\n  if (ex.getMessage().startsWith(\"Unknown annotation type\")) {\n    // internal inconsistency — report spring-aop / aspectjweaver version mismatch\n    throw new IllegalStateException(\"Spring/AspectJ version mismatch detected\", ex);\n  }\n  throw ex;\n}","preventionTips":["Pin spring-aop and aspectjweaver to compatible versions in your dependency management.","Do not fork the ASPECTJ_ANNOTATION_CLASSES array without updating annotationTypeMap."],"tags":["spring-aop","aspectj","internal","annotation"],"analyzedSha":"e8729d043887bf0d0baf91e062e909b56eb2b708","analyzedAt":"2026-08-04T19:07:39.725Z","schemaVersion":2}