alibaba/arthas · error · IllegalArgumentException

Invalid line number: {}

Error message

Invalid line number: {}

What it means

Thrown by the `line` command's parseLines() when a `--line` value fails Integer.parseInt (NumberFormatException). Arthas's `line` command watches local variables at specific source line numbers; the `--line` option accepts comma-separated positive integers only. Any token that is not a pure integer is rejected.

Source

Thrown at core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java:295

        for (String lineSpec : lineSpecs) {
            if (StringUtils.isEmpty(lineSpec)) {
                continue;
            }
            String[] parts = lineSpec.split(",");
            for (String part : parts) {
                String value = part.trim();
                if (value.length() == 0) {
                    continue;
                }
                if (value.indexOf('-') >= 0) {
                    throw new IllegalArgumentException("Line range syntax is not supported in the first version: "
                            + value);
                }
                final int lineNumber;
                try {
                    lineNumber = Integer.parseInt(value);
                } catch (NumberFormatException e) {
                    throw new IllegalArgumentException("Invalid line number: " + value);
                }
                if (lineNumber <= 0) {
                    throw new IllegalArgumentException("Line number must be greater than 0: " + value);
                }
                result.add(lineNumber);
                if (result.size() > MAX_LINE_COUNT) {
                    throw new IllegalArgumentException("Too many line numbers, maximum is " + MAX_LINE_COUNT + ".");
                }
            }
        }
        if (result.isEmpty()) {
            throw new IllegalArgumentException("The --line option is required unless --list-lines is used.");
        }
        return result;
    }

    private void listLines(CommandProcess process) {
        try {

View on GitHub (pinned to 21cf2e9ba5)

Solutions

  1. Supply only comma-separated positive integers, e.g. `--line 51,56,60`.
  2. Strip any non-digit characters from the --line value before running.
  3. If you wanted a range, list each line explicitly since range syntax is unsupported.
  4. Use `--list-lines --class <FQN>` first to discover valid line numbers.

Example fix

// before
line --class demo.MathGame --line 51,56a
// after
line --class demo.MathGame --line 51,56
Defensive patterns

Strategy: validation

Validate before calling

// Validate --line spec before invoking the line command
static boolean isValidLineSpec(String spec) {
    if (spec == null || spec.trim().isEmpty()) return false;
    for (String part : spec.split(",")) {
        String v = part.trim();
        if (v.isEmpty()) continue;
        if (v.indexOf('-') >= 0) return false;          // range syntax unsupported
        try { Integer.parseInt(v); } catch (NumberFormatException e) { return false; }
    }
    return true;
}

Type guard

null

Try / catch

null

Prevention

When it happens

Trigger: Running `line --class demo.MathGame --line abc`, `--line 12x`, `--line 1,foo,3`, or `--line 51;` (trailing punctuation). The offending comma-split part reaches Integer.parseInt and is not numeric.

Common situations: Typo in the line number; pasting line numbers copied from an IDE with extra formatting; mixing in a line-range like `51-56` with a malformed token (ranges are also rejected earlier at line 287); leaving a stray comma producing a non-numeric part such as `51,,53` is tolerated, but `51,a` is not.

Related errors


AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14). Data as JSON: /api/errors/cf3f1db0f4367b46. Report an issue: GitHub.