oracle/graal · error · IllegalArgumentException

multiline cannot be true when newLine is null

Error message

multiline cannot be true when newLine is null

What it means

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.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/bytecode/BytecodeDisassembler.java:171

    private final CPIFunction cpiFunction;

    /**
     * Creates a bytecode disassembler.
     *
     * @param multiline specifies if the disassembly for a single instruction can span multiple
     *            lines
     * @param newLine specifies the new line string to use. If null, all output is on one line.
     * @param format specifies if the disassembler should use {@link String#format} to do indenting
     *            and aligning
     */
    public BytecodeDisassembler(boolean multiline, String newLine, boolean format, CPIFunction cpiFunction) {
        this.multiline = multiline;
        this.newLine = newLine;
        this.format = format;
        this.cpiFunction = cpiFunction;
        if (multiline && newLine == null) {
            throw new IllegalArgumentException("multiline cannot be true when newLine is null");
        }
    }

    public BytecodeDisassembler(boolean multiline, String newLine) {
        this(multiline, newLine, true, CPIFunction.Identity);
    }

    public BytecodeDisassembler(boolean multiline) {
        this(multiline, System.lineSeparator(), true, CPIFunction.Identity);
    }

    public BytecodeDisassembler() {
        this(true, System.lineSeparator(), true, CPIFunction.Identity);
    }

    public static String disassembleOne(ResolvedJavaMethod method, int bci) {
        return new BytecodeDisassembler(false, null).disassemble(method, bci, bci);
    }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Pass a real separator when multiline is true: new BytecodeDisassembler(true, System.lineSeparator()).
  2. If you want one-line output, set multiline=false as well as newLine=null: new BytecodeDisassembler(false, null).
  3. Use the convenience constructor new BytecodeDisassembler(true) which fills in the platform line separator for you.

Example fix

// before
new BytecodeDisassembler(true, null); // throws

// after (multi-line output)
new BytecodeDisassembler(true, System.lineSeparator());

// after (single-line output)
new BytecodeDisassembler(false, null);
Defensive patterns

Strategy: validation

Validate before calling

boolean multiline = ...;
String newLine = ...;
if (multiline && newLine == null) {
    throw new IllegalArgumentException("multiline requires a non-null newLine");
}
BytecodeDisassembler d = new BytecodeDisassembler(multiline, newLine, format, cpi);

Prevention

When it happens

Trigger: 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().

Common situations: 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.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/fd1e10ddbfd45fbd. Report an issue: GitHub.