pxb1988/dex2jar · error · RuntimeException

arguments not equal:

Error message

arguments not equal: 

What it means

Thrown by InvocationWeaver.visitMethodInsn during a 'simple replace' of a STATIC invocation: for INVOKESTATIC the replacement must take exactly the same argument list as the original (no receiver), and Arrays.deepEquals(orgArgs, nArgs) fails when the descriptors differ in any way.

Solutions

  1. Align the replacement method's parameter list with the original (same count, types, and order).
  2. Use an invocation-interface mapping (mapTo taking the Invocation interface) instead of simple replace if argument adaptation is needed.
  3. Fix descriptor typos in the config so the mapped descriptor matches the original argument types.

Example fix

// before: replacing static '(II)V' with '(ILjava/lang/String;)V'
mapTo = Lcom/X;->f(ILjava/lang/String;)V
// after
mapTo = Lcom/X;->f(II)V
Defensive patterns

Strategy: validation

Validate before calling

// validate static->static replacement signatures before weaving
Type[] orgArgs = Type.getArgumentTypes(original.desc);
Type[] nArgs = Type.getArgumentTypes(mapTo.desc);
if (!Arrays.deepEquals(orgArgs, nArgs)) {
    throw new IllegalArgumentException("static replacement must keep identical arguments: "
        + Arrays.toString(orgArgs) + " vs " + Arrays.toString(nArgs));
}

Try / catch

try {
    new InvocationWeaver(cfg).weave();
} catch (RuntimeException e) {
    if (e.getMessage() != null && e.getMessage().startsWith("arguments not equal")) {
        throw new IllegalStateException("Fix the mapping so replacement arguments match the original", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: Mapping a static method call to another static method whose argument types (count or order) differ from the original, e.g. replacing '(II)V' with '(ILjava/lang/String;)V'.

Common situations: Hand-written weaving configs where the replacement method was refactored to accept different parameters, or mapping a static method to one intended for instance calls.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08). Data as JSON: /api/errors/0b5ad25ac1916e30. Report an issue: GitHub.

Appendix: source

Thrown at dex-tools/src/main/java/com/googlecode/d2j/tools/jar/InvocationWeaver.java:449

                        Type[] orgArgs = Type.getArgumentTypes(desc);
                        Type nRet = Type.getReturnType(mapTo.desc);
                        Type[] nArgs = Type.getArgumentTypes(mapTo.desc);
                        if (orgRet.getSort() != Type.VOID && nRet.getSort() == Type.VOID) {
                            throw new RuntimeException("can't cast " + nRet + " to " + orgRet);
                        }

                        if (nArgs.length == 1 && nArgs[0].getDescriptor().equals(invocationInterfaceDesc)) {
                            MtdInfo t = new MtdInfo();
                            t.owner = "L" + owner + ";";
                            t.name = name;
                            t.desc = desc;
                            MtdInfo n = newMethodA(opcode, t, mapTo);
                            super.visitMethodInsn(INVOKESTATIC, clzName, n.name, n.desc, isInterface);
                        } else { // simple replace
                            // checking for invalid replace
                            if (isStatic) {
                                if (!Arrays.deepEquals(orgArgs, nArgs)) {
                                    throw new RuntimeException("arguments not equal: " + owner + "." + name + desc
                                            + " <> " + mapTo.owner + "." + mapTo.name + mapTo.desc);
                                }
                            } else {
                                if (nArgs.length != orgArgs.length + 1) {
                                    throw new RuntimeException("arguments not equal: " + owner + "." + name + desc
                                            + " <> " + mapTo.owner + "." + mapTo.name + mapTo.desc);
                                }
                                if (orgArgs.length > 0) {
                                    for (int i = 0; i < orgArgs.length; i++) {
                                        if (!orgArgs[i].equals(nArgs[i + 1])) {
                                            throw new RuntimeException("arguments not equal: " + owner + "." + name
                                                    + desc + " <> " + mapTo.owner + "." + mapTo.name + mapTo.desc);
                                        }
                                    }
                                }
                            }
                            // replace it!
                            super.visitMethodInsn(INVOKESTATIC, toInternal(mapTo.owner), mapTo.name, mapTo.desc, isInterface);

View on GitHub (pinned to b5bda4fb49)