{"record":{"id":"fd1e10ddbfd45fbd","repo":"oracle/graal","slug":"multiline-cannot-be-true-when-newline-is-null","errorCode":null,"errorMessage":"multiline cannot be true when newLine is null","messagePattern":"multiline cannot be true when newLine is null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/bytecode/BytecodeDisassembler.java","lineNumber":171,"sourceCode":"\n    private final CPIFunction cpiFunction;\n\n    /**\n     * Creates a bytecode disassembler.\n     *\n     * @param multiline specifies if the disassembly for a single instruction can span multiple\n     *            lines\n     * @param newLine specifies the new line string to use. If null, all output is on one line.\n     * @param format specifies if the disassembler should use {@link String#format} to do indenting\n     *            and aligning\n     */\n    public BytecodeDisassembler(boolean multiline, String newLine, boolean format, CPIFunction cpiFunction) {\n        this.multiline = multiline;\n        this.newLine = newLine;\n        this.format = format;\n        this.cpiFunction = cpiFunction;\n        if (multiline && newLine == null) {\n            throw new IllegalArgumentException(\"multiline cannot be true when newLine is null\");\n        }\n    }\n\n    public BytecodeDisassembler(boolean multiline, String newLine) {\n        this(multiline, newLine, true, CPIFunction.Identity);\n    }\n\n    public BytecodeDisassembler(boolean multiline) {\n        this(multiline, System.lineSeparator(), true, CPIFunction.Identity);\n    }\n\n    public BytecodeDisassembler() {\n        this(true, System.lineSeparator(), true, CPIFunction.Identity);\n    }\n\n    public static String disassembleOne(ResolvedJavaMethod method, int bci) {\n        return new BytecodeDisassembler(false, null).disassemble(method, bci, bci);\n    }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/bytecode/BytecodeDisassembler.java#L153-L189","documentation":"BytecodeDisassembler's constructor validates its formatting arguments: multiline output is impossible without a line separator, so passing multiline=true together with newLine=null is rejected with this IllegalArgumentException. It is a straightforward API-contract check — if all output must be on one line, newLine must be null AND multiline must be false.","triggerScenarios":"Directly constructing new BytecodeDisassembler(true, null), or the (multiline, newLine, format, cpiFunction) overload with multiline=true and a null separator string. The convenience constructors (multiline only, or no-arg) never trigger it because they supply System.lineSeparator().","commonSituations":"Writing tooling that embeds disassembly into a single-line log record or JSON field and passing null for the separator while leaving multiline at its default true; refactoring code that previously used the one-arg constructor. Almost always a first-use programming error rather than an environment issue.","solutions":["Pass a real separator when multiline is true: new BytecodeDisassembler(true, System.lineSeparator()).","If you want one-line output, set multiline=false as well as newLine=null: new BytecodeDisassembler(false, null).","Use the convenience constructor new BytecodeDisassembler(true) which fills in the platform line separator for you."],"exampleFix":"// before\nnew BytecodeDisassembler(true, null); // throws\n\n// after (multi-line output)\nnew BytecodeDisassembler(true, System.lineSeparator());\n\n// after (single-line output)\nnew BytecodeDisassembler(false, null);","handlingStrategy":"validation","validationCode":"boolean multiline = ...;\nString newLine = ...;\nif (multiline && newLine == null) {\n    throw new IllegalArgumentException(\"multiline requires a non-null newLine\");\n}\nBytecodeDisassembler d = new BytecodeDisassembler(multiline, newLine, format, cpi);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the convenience constructors (new BytecodeDisassembler(true)) which supply a valid separator.","Encode the invariant 'multiline implies newLine != null' in one factory method used by all call sites."],"tags":["disassembler","constructor-validation","illegal-argument","bytecode"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}