{"record":{"id":"dc26cf0b9eaebe0e","repo":"chinabugotech/hutool","slug":"attribute-cannot-mirror-for-because-it","errorCode":null,"errorMessage":"attribute [{}] cannot mirror for [{}], because it's already mirrored for [{}]","messagePattern":"attribute \\[(.+?)\\] cannot mirror for \\[(.+?)\\], because it's already mirrored for \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/annotation/MirrorLinkAnnotationPostProcessor.java","lineNumber":111,"sourceCode":"\t\t}\n\t\t// 镜像字段已经跟其他字段形成镜像\n\t\telse if (!originalAttributeMirrored && mirrorAttributeMirrored) {\n\t\t\terrorMsg = CharSequenceUtil.format(\n\t\t\t\t\"attribute [{}] cannot mirror for [{}], because it's already mirrored for [{}]\",\n\t\t\t\tmirror.getAttribute(), original.getAttribute(), ((MirroredAnnotationAttribute)mirror).getLinked()\n\t\t\t);\n\t\t}\n\t\t// 两者都形成了镜像，但是都未指向对方，理论上不会存在该情况\n\t\telse {\n\t\t\terrorMsg = CharSequenceUtil.format(\n\t\t\t\t\"attribute [{}] cannot mirror for [{}], because [{}] already mirrored for [{}] and  [{}] already mirrored for [{}]\",\n\t\t\t\tmirror.getAttribute(), original.getAttribute(),\n\t\t\t\tmirror.getAttribute(), ((MirroredAnnotationAttribute)mirror).getLinked(),\n\t\t\t\toriginal.getAttribute(), ((MirroredAnnotationAttribute)original).getLinked()\n\t\t\t);\n\t\t}\n\n\t\tthrow new IllegalArgumentException(errorMsg);\n\t}\n\n\t/**\n\t * 基本校验\n\t */\n\tprivate void checkMirrorRelation(Link annotation, AnnotationAttribute original, AnnotationAttribute mirror) {\n\t\t// 镜像属性必须存在\n\t\tcheckLinkedAttributeNotNull(original, mirror, annotation);\n\t\t// 镜像属性返回值必须一致\n\t\tcheckAttributeType(original, mirror);\n\t\t// 镜像属性上必须存在对应的注解\n\t\tfinal Link mirrorAttributeAnnotation = getLinkAnnotation(mirror, RelationType.MIRROR_FOR);\n\t\tAssert.isTrue(\n\t\t\tObjectUtil.isNotNull(mirrorAttributeAnnotation) && RelationType.MIRROR_FOR.equals(mirrorAttributeAnnotation.type()),\n\t\t\t\"mirror attribute [{}] of original attribute [{}] must marked by @Link, and also @LinkType.type() must is [{}]\",\n\t\t\tmirror.getAttribute(), original.getAttribute(), RelationType.MIRROR_FOR\n\t\t);\n\t\tcheckLinkedSelf(original, mirror);","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/annotation/MirrorLinkAnnotationPostProcessor.java#L93-L129","documentation":"One of two near-identical messages from MirrorLinkAnnotationPostProcessor.checkMirrorRelation. This variant fires when an attribute is annotated @Link(type=MIRROR_FOR) pointing at another attribute, but that mirror relationship is inconsistent: specifically the branch where only one side has already been mirrored to a different target. It indicates a malformed mutual @Link/@MirrorFor setup that the processor cannot reconcile.","triggerScenarios":"Defining @Link(... MIRROR_FOR) on attribute A pointing to B, while B's @Link points elsewhere (or B has no reciprocal @Link), creating an asymmetric mirror graph. Mixing @Alias with @Link MIRROR_FOR on overlapping members.","commonSituations":"Building a custom composed-annotation hierarchy where mirrored members are not declared pairwise; refactoring one half of a mirror pair and forgetting the other; version upgrade that changed mirror semantics.","solutions":["Ensure MIRROR_FOR links are symmetric: if A mirrors B, B must mirror A.","Remove stray @Link annotations left from refactoring.","Inspect the error's listed attributes to find which side is double-linked and fix its @Link target."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify mirror pairs are symmetric before relying on synthesis\nboolean aMirrorsB = isMirrorFor(A.class, \"a\", B.class, \"b\");\nboolean bMirrorsA = isMirrorFor(B.class, \"b\", A.class, \"a\");\nif (aMirrorsB != bMirrorsA) throw new IllegalStateException(\"asymmetric mirror\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare @Link MIRROR_FOR on both members of a pair.","Avoid mixing @Alias and @Link MIRROR_FOR on the same member."],"tags":["annotation","mirror","link","reflection"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}