He can announce his problem and make the court aware of his problem. Which may get him the help he needs for recovery.

The court may order an evaluation, and then from that evaluation he maybe ordered to successfully complete treatment by his release from jail or probation.