{"record":{"id":"25636c79e271670b","repo":"alibaba/arthas","slug":"too-many-line-numbers-maximum-is-256","errorCode":null,"errorMessage":"Too many line numbers, maximum is 256.","messagePattern":"Too many line numbers, maximum is 256\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java","lineNumber":302,"sourceCode":"                if (value.length() == 0) {\n                    continue;\n                }\n                if (value.indexOf('-') >= 0) {\n                    throw new IllegalArgumentException(\"Line range syntax is not supported in the first version: \"\n                            + value);\n                }\n                final int lineNumber;\n                try {\n                    lineNumber = Integer.parseInt(value);\n                } catch (NumberFormatException e) {\n                    throw new IllegalArgumentException(\"Invalid line number: \" + value);\n                }\n                if (lineNumber <= 0) {\n                    throw new IllegalArgumentException(\"Line number must be greater than 0: \" + value);\n                }\n                result.add(lineNumber);\n                if (result.size() > MAX_LINE_COUNT) {\n                    throw new IllegalArgumentException(\"Too many line numbers, maximum is \" + MAX_LINE_COUNT + \".\");\n                }\n            }\n        }\n        if (result.isEmpty()) {\n            throw new IllegalArgumentException(\"The --line option is required unless --list-lines is used.\");\n        }\n        return result;\n    }\n\n    private void listLines(CommandProcess process) {\n        try {\n            Instrumentation instrumentation = process.session().getInstrumentation();\n            Set<Class<?>> classes = GlobalOptions.isDisableSubClass\n                    ? SearchUtils.searchClass(instrumentation, getClassNameMatcher())\n                    : SearchUtils.searchSubClass(instrumentation, SearchUtils.searchClass(instrumentation,\n                            getClassNameMatcher()));\n            if (classes.size() > maxNumOfMatchedClass) {\n                process.end(-1, \"The number of matched classes is \" + classes.size()","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/command/monitor200/LineCommand.java#L284-L320","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nline --class X --line 1,2,3,...,300\n// after\nline --class X --line 51,56,60   // keep <= 256 unique lines","handlingStrategy":"validation","validationCode":"static final int MAX_LINE_COUNT = 256;\nstatic String sanitizeLineSpec(String spec) {\n    Set<Integer> uniq = new LinkedHashSet<>();\n    for (String p : spec.split(\",\")) { String v=p.trim(); if(!v.isEmpty()) uniq.add(Integer.valueOf(v)); }\n    if (uniq.size() > MAX_LINE_COUNT)\n        throw new IllegalArgumentException(\"Too many lines: \" + uniq.size());\n    return uniq.stream().map(String::valueOf).collect(java.util.stream.Collectors.joining(\",\"));\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Cap generated line lists at 256 unique numbers.","Watch only the lines you actually need to inspect."],"tags":["arthas","line-command","limit","input-validation"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}