Judges and the justice system doesn't like it if you disrespect it. The worst thing you can do is question the legality of a judge to his face. It will end in "a sentence in the upper end of that range."
As someone who has gotten the maximum end of that upper range for the most bogus (and illegal) charge possible after trying to fight it in court instead of tucking my tail between my legs... Yes. You are correct. An overwhelming majority of judges take their jobs very personally and imagine themselves to be infallible embodiments of the law.