{"record":{"id":"add2389884904471","repo":"pxb1988/dex2jar","slug":"dup-clz-name","errorCode":null,"errorMessage":"dup clz: \" + name","messagePattern":"dup clz: \" \\+ name","errorType":"exception","errorClass":"DexWriteException","httpStatus":null,"severity":"error","filePath":"dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/ConstPool.java","lineNumber":223,"sourceCode":"    public AnnotationsDirectoryItem putAnnotationDirectoryItem() {\n        AnnotationsDirectoryItem aDirectoryItem = new AnnotationsDirectoryItem();\n        annotationsDirectoryItems.add(aDirectoryItem);\n        return aDirectoryItem;\n    }\n\n    public AnnotationItem uniqAnnotationItem(AnnotationItem key) {\n        AnnotationItem v = annotationItems.get(key);\n        if (v == null) {\n            annotationItems.put(key, key);\n            return key;\n        }\n        return v;\n    }\n\n    public ClassDefItem putClassDefItem(int accessFlag, String name, String superClass, String[] itfClass) {\n        TypeIdItem type = uniqType(name);\n        if (classDefs.containsKey(type)) {\n            throw new DexWriteException(\"dup clz: \" + name);\n        }\n        ClassDefItem classDefItem = new ClassDefItem();\n        classDefItem.accessFlags = accessFlag;\n        classDefItem.clazz = type;\n        if (superClass != null) {\n            classDefItem.superclazz = uniqType(superClass);\n        }\n        if (itfClass != null && itfClass.length > 0) {\n            classDefItem.interfaces = putTypeList(Arrays.asList(itfClass));\n        }\n        classDefs.put(type, classDefItem);\n        return classDefItem;\n    }\n\n    public FieldIdItem uniqField(Field field) {\n        return uniqField(field.getOwner(), field.getName(), field.getType());\n    }\n","sourceCodeStart":205,"sourceCodeEnd":241,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-writer/src/main/java/com/googlecode/d2j/dex/writer/item/ConstPool.java#L205-L241","documentation":"ConstPool.putClassDefItem() refuses to define the same class name twice; the pool already contains a ClassDefItem for the given type, so it throws DexWriteException('dup clz: <name>'). The dex format allows only one class_def entry per type.","triggerScenarios":"Calling putClassDefItem (directly or via DexFileWriter's class APIs) twice for the same class name within one DexFileWriter.","commonSituations":"Merging multiple class sources that both contain the same class; re-running a generation step against an existing DexFileWriter instance; duplicate class files on the input classpath (different casings resolved to same name).","solutions":["Deduplicate input classes before generation (keep one definition per class name)","Create a new DexFileWriter/Dex file for the second definition or skip already-added classes","Log and drop the second definition instead of adding it"],"exampleFix":"// before\nfor (Clz c : allClasses) writer.putClassDefItem(...);\n// after\nSet<String> seen = new HashSet<>();\nfor (Clz c : allClasses) { if (seen.add(c.name)) writer.putClassDefItem(...); }","handlingStrategy":"validation","validationCode":"if (poolContainsClass(name)) { skipOrMerge(name); } else { writer.putClassDefItem(access, name, superClz, itfs); }","typeGuard":null,"tryCatchPattern":"try { writer.putClassDefItem(access, name, superClz, itfs); } catch (DexWriteException e) { if (String.valueOf(e.getMessage()).startsWith(\"dup clz:\")) { /* skip duplicate */ return; } throw e; }","preventionTips":["Deduplicate class inputs (Set of class names) before generation","Use a fresh DexFileWriter per output dex","Handle multi-release/merged classpaths where duplicates are common"],"tags":["dex","duplicate-class","const-pool"],"backgroundTag":"file-already-exists","analyzedSha":"b5bda4fb4935ae8b3869b422454ae3b3896c7bc1","analyzedAt":"2026-09-08T00:44:01.258Z","contentChangedAt":"2026-09-08T00:44:01.258Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}