alibaba/arthas · error · IllegalArgumentException
Too many line numbers, maximum is 256.
Error message
Too many line numbers, maximum is 256.
What it means
Thrown by parseLines() in the `line` command when the accumulated distinct line numbers exceed MAX_LINE_COUNT (256, defined at LineCommand.java:41). Each unique line number is enhanced with bytecode instrumentation, so Arthas caps the count to bound overhead.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java:302
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 {
Instrumentation instrumentation = process.session().getInstrumentation();
Set<Class<?>> classes = GlobalOptions.isDisableSubClass
? SearchUtils.searchClass(instrumentation, getClassNameMatcher())
: SearchUtils.searchSubClass(instrumentation, SearchUtils.searchClass(instrumentation,
getClassNameMatcher()));
if (classes.size() > maxNumOfMatchedClass) {
process.end(-1, "The number of matched classes is " + classes.size()View on GitHub (pinned to 21cf2e9ba5)
Solutions
- Reduce the --line list to 256 or fewer unique numbers.
- Narrow the set to the lines you actually need to inspect.
- Run multiple `line` commands in sequence if you must watch more lines, rather than one giant spec.
Example fix
// before line --class X --line 1,2,3,...,300 // after line --class X --line 51,56,60 // keep <= 256 unique lines
Defensive patterns
Strategy: validation
Validate before calling
static final int MAX_LINE_COUNT = 256;
static String sanitizeLineSpec(String spec) {
Set<Integer> uniq = new LinkedHashSet<>();
for (String p : spec.split(",")) { String v=p.trim(); if(!v.isEmpty()) uniq.add(Integer.valueOf(v)); }
if (uniq.size() > MAX_LINE_COUNT)
throw new IllegalArgumentException("Too many lines: " + uniq.size());
return uniq.stream().map(String::valueOf).collect(java.util.stream.Collectors.joining(","));
} Type guard
null
Try / catch
null
Prevention
- Cap generated line lists at 256 unique numbers.
- Watch only the lines you actually need to inspect.
When it happens
Trigger: Running `line --class X --line` with a comma-separated list containing more than 256 unique line numbers (e.g. generated ranges expanded manually), or repeatedly calling with a large generated spec.
Common situations: Programmatically building a line list that exceeds the cap; trying to watch every line of a large method; misunderstanding that the cap counts unique lines, not spec strings.
Related errors
- Invalid line number: {}
- Line number must be greater than 0: {}
- sizeLimit must be greater than 0.
- Time fragment index is expected, please type -i to specify
- 必须提供 path 或 cursor
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/25636c79e271670b.
Report an issue: GitHub.