Well, he shouldn’t be convicted. The courts should deem the law to be unacceptable (unconstitutional, against international human rights, whatever) and strike it down. That’s how it would work in Canada or the US anyway.
Of course those laws exist in every country, in every state and province, in every municipality. I agree that it would be better if the law got a regular, thorough cleaning, but it doesn’t. German law is presumably different than English-tradition law that I’m familiar with, and maybe the prosecutors have some kind of obligation to prosecute? Around here a prosecutor would look at that law and say, “Well, that law is obviously unconstitutional, so I’m not wasting my office’s resources taking it to court.”