{"record":{"id":"5f8497ec0a4d245e","repo":"pxb1988/dex2jar","slug":"cant-mix-use-param-and-parameter-on-method","errorCode":null,"errorMessage":"cant mix use .param and .parameter on method","messagePattern":"cant mix use \\.param and \\.parameter on method","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"d2j-smali/src/main/java/com/googlecode/d2j/smali/AntlrSmaliUtil.java","lineNumber":705,"sourceCode":"        return totalRegisters;\n    }\n\n    private static void acceptParameter(List<SmaliParser.SParameterContext> sParameterContexts, M m, DexMethodVisitor dexMethodVisitor) {\n        if (sParameterContexts == null || sParameterContexts.size() == 0 || dexMethodVisitor == null) {\n            return;\n        }\n        boolean hasParam = false;\n        boolean hasParamter = false;\n        for (SmaliParser.SParameterContext ctx : sParameterContexts) {\n            if (ctx.param != null) {\n                hasParam = true;\n            }\n            if (ctx.parameter != null) {\n                hasParamter = true;\n            }\n        }\n        if (hasParam && hasParamter) {\n            throw new RuntimeException(\"cant mix use .param and .parameter on method\");\n        }\n        for (int i = 0; i < sParameterContexts.size(); i++) {\n            SmaliParser.SParameterContext ctx = sParameterContexts.get(i);\n            int index;\n            if (ctx.param != null) {\n                index = m.regToParamIdx(m.pareReg(ctx.r.getText()));\n            } else {\n                index = i;\n            }\n            if (ctx.name != null) {\n                m.setNameByIdx(index, unescapeStr(ctx.name.getText()));\n            }\n            List<SmaliParser.SAnnotationContext> annotationContexts = ctx.sAnnotation();\n            if (annotationContexts.size() > 0) {\n                acceptAnnotations(annotationContexts, dexMethodVisitor.visitParameterAnnotation(index));\n            }\n        }\n","sourceCodeStart":687,"sourceCodeEnd":723,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/d2j-smali/src/main/java/com/googlecode/d2j/smali/AntlrSmaliUtil.java#L687-L723","documentation":"AntlrSmaliUtil collects parameter declarations for a method from smali, which historically supported two syntaxes: the newer .param and the older .parameter directive. During method parsing it checks both contexts and throws RuntimeException('cant mix use .param and .parameter on method') if a single method body uses both forms. Mixing them makes register-to-parameter-index mapping ambiguous, so the parser refuses.","triggerScenarios":"A smali method declares some parameters with .param (e.g. .param p0) and others with .parameter (e.g. .parameter a, .parameter b) in the same method, parsed via AntlrSmaliUtil or d2j-smali/baksmali workflows.","commonSituations":"Merging or hand-editing smali from two sources (new baksmali output pasted into old-style code), partial migration of a decompiled method to the newer syntax, or copy-pasted prologue lines from different methods.","solutions":["Edit the smali so the method uses only one syntax: convert all .parameter directives to .param form (or vice versa).","Regenerate the smali with a single consistent baksmali version instead of mixing outputs.","Check both branches around the reported method for stray .param/.parameter lines.","Catch the RuntimeException around parsing to locate the offending method and fix it.","Re-assemble after cleanup to confirm no mixed directives remain."],"exampleFix":"// before\n.method public foo(I)V\n    .param p1, \"x\"\n    .parameter \"y\"\n\n// after\n.method public foo(II)V\n    .param p1, \"x\"\n    .param p2, \"y\"","handlingStrategy":"validation","validationCode":"boolean sawParam = false, sawParameter = false;\nfor (String line : Files.readAllLines(smaliFile)) {\n    String t = line.strip();\n    if (t.startsWith(\".param \")) sawParam = true;\n    if (t.startsWith(\".parameter\")) sawParameter = true;\n}\nif (sawParam && sawParameter) throw new IllegalStateException(\"Mixed .param and .parameter in smali\");","typeGuard":null,"tryCatchPattern":"try {\n    AntlrSmaliUtil.parse(file);\n} catch (RuntimeException e) {\n    if (e.getMessage().contains(\"cant mix use .param and .parameter\")) {\n        System.err.println(\"Normalize parameter directives in \" + file + \" to one syntax.\");\n    } else throw e;\n}","preventionTips":["Use one baksmali version to generate all smali so parameter syntax is uniform.","Grep for '.parameter' when migrating codebases to the .param syntax.","Never paste method prologues from differently-styled decompiled sources.","Pre-scan smali trees for mixed directives before running conversion."],"tags":["smali","parser","conflict","syntax"],"backgroundTag":"mutually-exclusive-options","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"}