pxb1988/dex2jar · error · DexException

not a validate Method Desc

Error message

not a validate Method Desc %s

What it means

Types.getParameterTypeDesc parses an ASM-style method descriptor such as '(II)V' into its parameter type descriptors. It validates that the descriptor begins with '(' and throws DexException 'not a validate Method Desc %s' immediately if the first character is not '(' — the descriptor is malformed.

Solutions

  1. Verify the string is a full method descriptor starting with '(' and containing ')', e.g. '(II)V', before calling
  2. Print/inspect the offending desc in the exception message to find where the truncated or wrong value originates
  3. If the input may be a bare type, use the type-descriptor parser instead of the method-descriptor one
  4. Check upstream callers (e.g. dex method parsing) for corrupted descriptors from a damaged/obfuscated dex file — try re-obtaining the dex from the original APK

Example fix

// before
String[] ps = Types.getParameterTypeDesc("II");
// after
String desc = "(II)V";
if (desc != null && desc.startsWith("(")) {
    String[] ps = Types.getParameterTypeDesc(desc);
}
Defensive patterns

Strategy: validation

Validate before calling

public static void requireMethodDesc(String desc) {
    if (desc == null || desc.isEmpty() || desc.charAt(0) != '(')
        throw new IllegalArgumentException("not a method desc: " + desc);
}

Type guard

static boolean isMethodDesc(String s) {
    return s != null && s.startsWith("(") && s.indexOf(')') > 0;
}

Try / catch

try {
    String[] ps = Types.getParameterTypeDesc(desc);
} catch (DexException e) {
    // log e.getMessage() which embeds the offending desc and fix upstream
}

Prevention

When it happens

Trigger: Calling Types.getParameterTypeDesc(desc) with a string whose first char is not '(', e.g. passing a bare type desc like 'I' or 'Ljava/lang/String;', an empty string, a plain class name, or a signature instead of a method descriptor.

Common situations: Mixing up field/type descriptors with method descriptors when reflecting on dex/asm types; passing a Proguard-smali style name; reading a descriptor from a malformed or obfuscated dex entry; off-by-one substring slicing upstream stripping the '(' character.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


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

Appendix: source

Thrown at dex-translator/src/main/java/com/googlecode/d2j/util/Types.java:17

package com.googlecode.d2j.util;

import com.googlecode.d2j.DexException;

import java.util.ArrayList;
import java.util.List;

public class Types {
    /**
     * @param desc
     *            a asm method desc, ex: (II)V
     * @return a array of argument types, ex: [I,I]
     */
    public static String[] getParameterTypeDesc(String desc) {

        if (desc.charAt(0) != '(') {
            throw new DexException("not a validate Method Desc %s", desc);
        }
        int x = desc.lastIndexOf(')');
        if (x < 0) {
            throw new DexException("not a validate Method Desc %s", desc);
        }
        List<String> ps = listDesc(desc.substring(1, x - 1));
        return ps.toArray(new String[ps.size()]);
    }

    /**
     * 
     * @param desc
     *            a asm method desc, ex: (II)V
     * @return the desc of return type, ex: V
     */
    public static String getReturnTypeDesc(String desc) {
        int x = desc.lastIndexOf(')');
        if (x < 0) {

View on GitHub (pinned to b5bda4fb49)