{"record":{"id":"780afe08f139199d","repo":"pxb1988/dex2jar","slug":"cv-class-version-out-of-range-1-18-is-supporte","errorCode":null,"errorMessage":"-cv,--class-version out of range, 1-18 is supported.","messagePattern":"-cv,--class-version out of range, 1-18 is supported\\.","errorType":"validation","errorClass":"HelpException","httpStatus":null,"severity":"error","filePath":"d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java","lineNumber":69,"sourceCode":"\n    @Opt(opt = \"cv\", longOpt = \"class-version\", description = \"default .class version, [1~9], default 8 for JAVA8\")\n    private int classVersion = 8;\n\n    public Jasmin2JarCmd() {\n    }\n\n    public static void main(String... args) throws ClassNotFoundException, SecurityException {\n        new Jasmin2JarCmd().doMain(args);\n    }\n\n    @Override\n    protected void doCommandLine() throws Exception {\n        if (remainingArgs.length != 1) {\n            usage();\n            return;\n        }\n        if (classVersion < 1 || classVersion > 18) {\n            throw new HelpException(\"-cv,--class-version out of range, 1-18 is supported.\");\n        }\n\n        Path jar = new File(remainingArgs[0]).toPath().toAbsolutePath();\n        if (!Files.exists(jar)) {\n            System.err.println(jar + \" doesn't exist\");\n            usage();\n            return;\n        }\n\n        if (output == null) {\n            output = new File(getBaseName(jar) + \"-jasmin2jar/\").toPath();\n        }\n\n        if (Files.exists(output) && !forceOverwrite) {\n            System.err.println(output + \" exists, use --force to overwrite\");\n            usage();\n            return;\n        }","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/pxb1988/dex2jar/blob/b5bda4fb4935ae8b3869b422454ae3b3896c7bc1/d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java#L51-L87","documentation":"Jasmin2JarCmd validates the -cv/--class-version option in doCommandLine before converting Jasmin assembly to a jar. The Java class file major version mapped by this tool is expressed as 1..18; anything outside that range cannot be emitted, so it throws HelpException with an out-of-range message. The CLI aborts rather than silently clamping the value.","triggerScenarios":"Invoking d2j-jasmin2jar with -cv set to a value less than 1 or greater than 18, e.g. -cv 0, -cv 19, -cv 52.0 (non-integer parse results landing out of range), or passing a Java version number like 17 vs a class-file major version the tool doesn't accept.","commonSituations":"Confusing Java SE release numbers with class file major versions and passing values like 52 or 19; copy-pasting flags from a different tool that uses a different version scale; typos like -cv 1.8.","solutions":["Pass -cv with a value between 1 and 18, e.g. -cv 17 for a modern target.","Consult the tool usage (-h) to confirm the accepted version scale.","If targeting the newest Java, pick the highest supported value (18) or upgrade dex2jar for newer support.","Check wrapper scripts for hardcoded -cv values and correct out-of-range entries."],"exampleFix":"// before\nd2j-jasmin2jar.sh -cv 52 -o out.jar src/\n\n// after\nd2j-jasmin2jar.sh -cv 8 -o out.jar src/","handlingStrategy":"validation","validationCode":"int cv = Integer.parseInt(classVersionArg);\nif (cv < 1 || cv > 18) {\n    throw new IllegalArgumentException(\"-cv must be 1-18, got \" + cv);\n}","typeGuard":null,"tryCatchPattern":"try {\n    Jasmin2JarCmd.doMain(new String[]{\"-cv\", \"8\", \"-o\", \"out.jar\", \"src\"});\n} catch (BaseCmd.HelpException e) {\n    System.err.println(\"Invalid class-version or usage; see help above.\");\n    System.exit(2);\n}","preventionTips":["Map Java SE releases to accepted -cv values once and reuse the mapping.","Never pass floating-point or Java-brand version numbers to -cv.","Pin the -cv value in wrapper scripts and review it on dex2jar upgrades.","Validate the flag with a range check before invoking the CLI."],"tags":["cli","validation","jasmin","class-version"],"backgroundTag":"invalid-cli-argument","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"}