{"record":{"id":"27c6e9b2dd8ffc82","repo":"skylot/jadx","slug":"class-alias-can-t-be-empty","errorCode":null,"errorMessage":"Class alias can't be empty","messagePattern":"Class alias can't be empty","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"jadx-core/src/main/java/jadx/core/dex/info/ClassAliasInfo.java","lineNumber":16,"sourceCode":"package jadx.core.dex.info;\n\nimport org.jetbrains.annotations.Nullable;\n\nimport jadx.core.utils.StringUtils;\n\nclass ClassAliasInfo {\n\tprivate final String shortName;\n\t@Nullable\n\tprivate final String pkg;\n\t@Nullable\n\tprivate String fullName;\n\n\tClassAliasInfo(@Nullable String pkg, String shortName) {\n\t\tif (StringUtils.isEmpty(shortName)) {\n\t\t\tthrow new IllegalArgumentException(\"Class alias can't be empty\");\n\t\t}\n\t\tthis.pkg = pkg;\n\t\tthis.shortName = shortName;\n\t}\n\n\t@Nullable\n\tpublic String getPkg() {\n\t\treturn pkg;\n\t}\n\n\tpublic String getShortName() {\n\t\treturn shortName;\n\t}\n\n\t@Nullable\n\tpublic String getFullName() {\n\t\treturn fullName;\n\t}","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/skylot/jadx/blob/e738a26571d02919f01df40de93bc9a44dee4e18/jadx-core/src/main/java/jadx/core/dex/info/ClassAliasInfo.java#L1-L34","documentation":"IllegalArgumentException thrown by the ClassAliasInfo constructor when the supplied short class alias name is null or empty (StringUtils.isEmpty). It is a precondition guard ensuring every class alias has a non-blank name. This is one of the few errors thrown as IllegalArgumentException rather than JadxRuntimeException.","triggerScenarios":"Calling rename/alias APIs (ClassInfo.changeShortName or anything that builds a ClassAliasInfo) with an empty or null short name - e.g. user-driven rename in the GUI with a blank field, or programmatic aliasing with an empty string.","commonSituations":"User clears a class alias in the jadx GUI; a deobfuscation/rename script supplies an empty name; trimming user input to empty; null passed by mistake from a mapping file.","solutions":["Validate the alias is non-blank before renaming: reject empty/whitespace and prompt the user.","If the intent is to clear/reset an alias, use the API path that removes the alias (set alias to null) rather than setting an empty short name.","Trim and check: if (name == null || name.trim().isEmpty()) do not call the constructor.","Catch IllegalArgumentException at the rename-call boundary to give a user-friendly message in GUI/script contexts."],"exampleFix":"// before\nClassAliasInfo alias = new ClassAliasInfo(pkg, newName); // throws if newName empty\n\n// after\nString name = newName == null ? \"\" : newName.trim();\nif (name.isEmpty()) {\n    // clear alias instead of creating an empty one\n    classInfo.removeAlias();\n} else {\n    ClassAliasInfo alias = new ClassAliasInfo(pkg, name);\n}","handlingStrategy":"validation","validationCode":"String name = newName == null ? \"\" : newName.trim();\nif (name.isEmpty()) {\n    // do not create an empty alias; clear it instead\n    return;\n}","typeGuard":"static boolean isValidAliasName(String s) {\n    return s != null && !s.trim().isEmpty();\n}","tryCatchPattern":"try {\n    classInfo.changeShortName(newName);\n} catch (IllegalArgumentException e) {\n    // surface a user-friendly message in GUI/script contexts\n    throw new ValidationException(\"Class alias name must not be empty\");\n}","preventionTips":["Trim and validate alias names before renaming.","To clear an alias, use the remove/clear API rather than an empty string.","Catch IllegalArgumentException at the rename-call boundary for user-facing tools."],"tags":["alias","rename","validation","precondition"],"backgroundTag":null,"analyzedSha":"e738a26571d02919f01df40de93bc9a44dee4e18","analyzedAt":"2026-08-14T00:10:24.238Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}