{"record":{"id":"169a26a4c351ff00","repo":"chinabugotech/hutool","slug":"no-method-for-alias","errorCode":null,"errorMessage":"No method for alias: [{}]","messagePattern":"No method for alias: \\[(.+?)\\]","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hutool-core/src/main/java/cn/hutool/core/annotation/AnnotationProxy.java","lineNumber":54,"sourceCode":"\t\tthis.attributes = initAttributes();\n\t}\n\n\n\t@Override\n\tpublic Class<? extends Annotation> annotationType() {\n\t\treturn type;\n\t}\n\n\t@Override\n\tpublic Object invoke(Object proxy, Method method, Object[] args) throws Throwable {\n\n\t\t// 注解别名\n\t\tAlias alias = method.getAnnotation(Alias.class);\n\t\tif(null != alias){\n\t\t\tfinal String name = alias.value();\n\t\t\tif(StrUtil.isNotBlank(name)){\n\t\t\t\tif(false == attributes.containsKey(name)){\n\t\t\t\t\tthrow new IllegalArgumentException(StrUtil.format(\"No method for alias: [{}]\", name));\n\t\t\t\t}\n\t\t\t\treturn attributes.get(name);\n\t\t\t}\n\t\t}\n\n\t\tfinal Object value = attributes.get(method.getName());\n\t\tif (value != null) {\n\t\t\treturn value;\n\t\t}\n\t\treturn method.invoke(this, args);\n\t}\n\n\t/**\n\t * 初始化注解的属性<br>\n\t * 此方法预先调用所有注解的方法，将注解方法值缓存于attributes中\n\t *\n\t * @return 属性（方法结果）映射\n\t */","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-core/src/main/java/cn/hutool/core/annotation/AnnotationProxy.java#L36-L72","documentation":"An annotation attribute declared an @Alias(\"name\") whose target name does not exist among the annotation's member methods. AnnotationProxy.invoke looks up the alias name in the attributes map and, finding no matching method, rejects the configuration at proxy construction time. This surfaces during annotation synthesis/resolution, typically when the annotated type is first introspected.","triggerScenarios":"Writing @Alias(\"foo\") on a member whose sibling member is actually named bar (typo or rename). Using @Alias to cross-reference an attribute that was removed/renamed between library versions. Combining @Alias with an inherited meta-annotation whose target attribute is not present on the concrete annotation.","commonSituations":"Refactoring annotation members without updating @Alias targets; copy-pasting an @Alias value; version mismatch where a dependency annotation changed member names.","solutions":["Verify the @Alias value exactly matches an existing member method name on the same annotation (case-sensitive).","Re-run after renaming the alias target back or updating the @Alias string.","Search the codebase for the referenced name to confirm it still exists."],"exampleFix":"// before\npublic @interface Config {\n  String path();\n  @Alias(\"location\") String path2(); // location does not exist\n}\n// after\npublic @interface Config {\n  String location();\n  @Alias(\"location\") String path();\n}","handlingStrategy":"validation","validationCode":"Set<String> members = Stream.of(ann.annotationType().getDeclaredMethods())\n    .map(Method::getName).collect(Collectors.toSet());\nfor (Method m : ann.annotationType().getDeclaredMethods()) {\n  Alias a = m.getAnnotation(Alias.class);\n  if (a != null && !members.contains(a.value())) throw new IllegalStateException(\"bad alias target: \" + a.value());\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep @Alias targets and member names in sync during refactors.","Add a unit test that synthesizes each custom annotation to catch alias errors at build time."],"tags":["annotation","alias","reflection","config"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}