§1. Defects which can render the sentence null can be introduced as exceptions at any stage or grade of the trial; the judge can likewise declare them ex officio.
§2. In addition to the cases mentioned in §1, dilatory exceptions, especially those which regard the persons and the manner of the trial, must be proposed before the joinder of the issue unless they emerged after the issue was already joined; they must be decided as soon as possible.
Source: Code of Canon Law (Vatican.va)