{"record":{"id":"1cf1939ff1fc3e5b","repo":"pxb1988/dex2jar","slug":"failed-to-add-hex-class-location-decode","errorCode":null,"errorMessage":"Failed to add HEX_CLASS_LOCATION.decode_*","messagePattern":"Failed to add HEX_CLASS_LOCATION\\.decode_\\*","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java","lineNumber":584,"sourceCode":"                                        hexDecodeMethodNameBase + \"$\" + name, desc, signature, exceptions)) {\n                            @Override\n                            public void visitMethodInsn(int opcode, String owner, String name, String descriptor,\n                                                        boolean isInterface) {\n                                if (owner.equals(HEX_CLASS_LOCATION)) {\n                                    super.visitMethodInsn(opcode, className, hexDecodeMethodNameBase + \"$\" + name,\n                                            descriptor, isInterface);\n                                } else {\n                                    super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);\n                                }\n                            }\n                        };\n                    } else {\n                        return super.visitMethod(access, name, desc, signature, exceptions);\n                    }\n                }\n            }, ClassReader.EXPAND_FRAMES);\n        } catch (Throwable t) {\n            throw new RuntimeException(\"Failed to add \" + HEX_CLASS_LOCATION + \".decode_*\", t);\n        }\n    }\n    public void convertCode(DexMethodNode methodNode, MethodVisitor mv, ClzCtx clzCtx) {\n        IrMethod irMethod = dex2ir(methodNode);\n        optimize(irMethod);\n        ir2j(irMethod, mv, clzCtx);\n    }\n\n    public void convertDex(DexFileNode fileNode, ClassVisitorFactory cvf) {\n        if (fileNode.clzs != null) {\n            Map<String, Clz> classes = collectClzInfo(fileNode);\n            for (DexClassNode classNode : fileNode.clzs) {\n                convertClass(fileNode, classNode, cvf, classes);\n            }\n        }\n    }\n\n    public void convertField(DexClassNode classNode, DexFieldNode fieldNode, ClassVisitor cv) {","sourceCodeStart":566,"sourceCodeEnd":602,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java#L566-L602","documentation":"Dex2Asm injects the synthetic HEX_CLASS_LOCATION.decode_* helper method (a hex-decoding bootstrap used to embed large byte arrays in generated classes) into output classes via ASM. If any Throwable escapes that visit/injection process, it is rethrown wrapped as 'Failed to add HEX_CLASS_LOCATION.decode_*'. The root cause is in the chained throwable, not the message itself.","triggerScenarios":"Running the code path that augments generated classes with the hex-decode helper — e.g. ASM errors (MethodTooLargeException, ClassFormatError), ASM version incompatibilities, or memory issues while writing the enlarged class during jar2dex conversion.","commonSituations":"Converting very large methods/data arrays where the synthesized decode_* method exceeds the 64KB method limit (MethodTooLargeException), or class format/ASM version mismatches in dex-to-jar translation pipelines.","solutions":["Read the chained cause (t) to find the real failure — most often MethodTooLargeException from overly large embedded data","Reduce the size of the embedded data/method being converted, or split it into multiple classes/methods","Upgrade dex-translator and its ASM dependency to compatible versions","Increase heap only if the cause is OutOfMemoryError"],"exampleFix":"// diagnosing\ntry { dex2asm.convert(...); } catch (RuntimeException e) {\n    e.getCause().printStackTrace(); // real reason, e.g. MethodTooLargeException\n}\n// before: one giant data blob in a single method\n// after: split embedded arrays across multiple classes/methods","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    dex2asm.convert(...);\n} catch (RuntimeException e) {\n    Throwable cause = e.getCause();\n    if (cause instanceof MethodTooLargeException) {\n        // split the offending data/method and retry\n    } else if (cause instanceof OutOfMemoryError || cause instanceof ClassFormatError) {\n        log.error(\"class generation failed\", cause);\n    } else throw e;\n}","preventionTips":["Always inspect getCause() — the message names the wrapper, not the fault","Avoid embedding very large arrays in single methods/classes","Keep ASM dependency versions aligned with dex-translator","Monitor generated class sizes; split large constants across classes"],"tags":["asm","bytecode-generation","dex2asm","wrapped-exception"],"backgroundTag":"internal-invariant-violation","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"}