protected JCDiagnostic(Messages messages,
                       DiagnosticType dt,
                       boolean mandatory,
                       DiagnosticSource source,
                       DiagnosticPosition pos,
                       String key,
                       Object ... args) {
        if (source == null && pos != null && pos.getPreferredPosition() != Position.NOPOS)
            throw new IllegalArgumentException();

        this.messages = messages;
        this.type = dt;
        this.mandatory = mandatory;
        this.source = source;
        this.position = pos;
        this.key = key;
        this.args = args;

        int n = (pos == null ? Position.NOPOS : pos.getPreferredPosition());
        if (n == Position.NOPOS || source == null)
            line = column = -1;
        else {
            line = source.getLineNumber(n);
            column = source.getColumnNumber(n);
        }
    }