{"record":{"id":"82690e4c056f6abf","repo":"pxb1988/dex2jar","slug":"array-is-used-multiple-times","errorCode":null,"errorMessage":"array is used multiple times","messagePattern":"array is used multiple times","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/array/FillArrayTransformer.java","lineNumber":220,"sourceCode":"                    }\r\n                    return v;\r\n                }\r\n            };\r\n\r\n            if (ao.used.size() == 1) {\r\n                Stmt stmt = ao.used.get(0);\r\n                if (method.stmts.contains(stmt)) { // the stmt is not removed by pre array replacement\r\n                    Cfg.travelMod(stmt, tcb, false);\r\n                } else {\r\n                    int size = filledArrayExprs.size();\r\n                    for (int i = 0; i < size; i++) {\r\n                        Cfg.travelMod(filledArrayExprs.get(i), tcb);\r\n                    }\r\n                }\r\n            } else if (ao.used.size() == 0) {\r\n                // the array is never used, ignore\r\n            } else {\r\n                throw new RuntimeException(\"array is used multiple times\");\r\n            }\r\n        }\r\n    }\r\n\r\n    // FIXME poor performance\r\n    private void makeSureArrayUsedAfterAllElementAssigned(IrMethod method, final Map<Local, ArrayObject> arraySizes) {\r\n\r\n        for (Local local : method.locals) {\r\n            local._ls_index = -1;\r\n        }\r\n        final int MAX = 50;\r\n        if (arraySizes.size() < MAX) {\r\n            makeSureArrayUsedAfterAllElementAssigned0(method, arraySizes);\r\n        } else {\r\n\r\n            // this method consumes too many memory, case 'java.lang.OutOfMemoryError: Java heap space', we have to cut\r\n            // it\r\n            Map<Local, ArrayObject> keptInAll = new HashMap<>();\r","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/dex-ir/src/main/java/com/googlecode/dex2jar/ir/ts/array/FillArrayTransformer.java#L202-L238","documentation":"FillArrayTransformer lowers filled-array IR (fill-array-data). For each created array it expects either exactly one use of the array or zero uses. If the array local is referenced more than once after creation (it cannot rewrite a filled array whose reference escapes to multiple consumers), it throws this RuntimeException.","triggerScenarios":"Running FillArrayTransformer.transform on an IrMethod where a Local holding a filled-array value (NewFilledArrayExpr) is used by more than one statement, so ao.used.size() > 1.","commonSituations":"DEX code that copies a filled-array reference into several registers or passes it to two calls; IR produced by earlier passes that duplicated local uses without SSA renaming.","solutions":["Re-check which pass duplicated the array local's uses; run SSA/local renaming so each value has one use","Keep FillArrayTransformer ordered after the passes it depends on (as in the default Transform pipeline)","Rewrite the method to use the array reference only once before translation","Catch the exception and fall back to skipping fill-array lowering for that method"],"exampleFix":"// guard in caller\ntry {\n    method = new FillArrayTransformer().transform(method);\n} catch (RuntimeException e) {\n    if (!e.getMessage().startsWith(\"array is used\")) throw e;\n    LOG.warn(\"skipping fill-array transform for \" + method); // keep untransformed method\n}","handlingStrategy":"validation","validationCode":"// before transforming, assert single use of filled-array locals\nfor (Local arr : filledArrayLocals) {\n    if (method.countUsesOf(arr) > 1) {\n        throw new IllegalStateException(\"array local \" + arr + \" used multiple times\");\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    method = new FillArrayTransformer().transform(method);\n} catch (RuntimeException e) {\n    if (e.getMessage() == null || !e.getMessage().contains(\"array is used multiple times\")) throw e;\n    // keep untransformed method\n}","preventionTips":["Ensure SSA/single-use locals before array transformers","Preserve the documented transformer order in the pipeline","Test translation against DEX that reuses array references"],"tags":["ir","array","transform"],"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"}