Maybe not "this law I broke shouldn't exist" on its own, but "this law I broke shouldn't exist according to the constitution of our country" or "this law I broke shouldn't exist because it conflicts with this other guaranteed legal protection" is a perfectly ordinary defense. It's one of the core functions of a functioning judicial system.