pxb1988/dex2jar · error · HelpException
-cv,--class-version out of range, 1-18 is supported.
Error message
-cv,--class-version out of range, 1-18 is supported.
What it means
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.
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.
Example fix
// before d2j-jasmin2jar.sh -cv 52 -o out.jar src/ // after d2j-jasmin2jar.sh -cv 8 -o out.jar src/
Defensive patterns
Strategy: validation
Validate before calling
int cv = Integer.parseInt(classVersionArg);
if (cv < 1 || cv > 18) {
throw new IllegalArgumentException("-cv must be 1-18, got " + cv);
} Try / catch
try {
Jasmin2JarCmd.doMain(new String[]{"-cv", "8", "-o", "out.jar", "src"});
} catch (BaseCmd.HelpException e) {
System.err.println("Invalid class-version or usage; see help above.");
System.exit(2);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- can't convert [ ] to type
- ERROR: Unrecognized option
- ERROR: Option need an argument value
- ERROR: Options: is required
- Fail to assemble
AI-assisted analysis of pxb1988/dex2jar@b5bda4fb49 (2026-09-08).
Data as JSON: /api/errors/780afe08f139199d.
Report an issue: GitHub.
Appendix: source
Thrown at d2j-jasmin/src/main/java/com/googlecode/d2j/jasmin/Jasmin2JarCmd.java:69
@Opt(opt = "cv", longOpt = "class-version", description = "default .class version, [1~9], default 8 for JAVA8")
private int classVersion = 8;
public Jasmin2JarCmd() {
}
public static void main(String... args) throws ClassNotFoundException, SecurityException {
new Jasmin2JarCmd().doMain(args);
}
@Override
protected void doCommandLine() throws Exception {
if (remainingArgs.length != 1) {
usage();
return;
}
if (classVersion < 1 || classVersion > 18) {
throw new HelpException("-cv,--class-version out of range, 1-18 is supported.");
}
Path jar = new File(remainingArgs[0]).toPath().toAbsolutePath();
if (!Files.exists(jar)) {
System.err.println(jar + " doesn't exist");
usage();
return;
}
if (output == null) {
output = new File(getBaseName(jar) + "-jasmin2jar/").toPath();
}
if (Files.exists(output) && !forceOverwrite) {
System.err.println(output + " exists, use --force to overwrite");
usage();
return;
}View on GitHub (pinned to b5bda4fb49)