Of course the courts can but in practice never do. The 2A community has been dealing with the courts reticence to deal with patently unconstitutional laws for the last 100 years.