When Jeremiah Hupka took the oath as a Hunterdon County Sheriff’s officer, he placed a hand on a Bible and vowed “to support and comply with the Constitution of the United States of America, and the constitution and laws of the state of New Jersey,” among other things.

So help him, God.

In the end, this was just theater for family and friends and the taxpayers who pay him to keep them safe, because that oath (and others) have been rendered farcical by the state Supreme Court.

Choosing bad law over common sense, the court ruled that Hupka, despite pleading guilty to sexually assaulting a former girlfriend — and thereby violating the laws he vowed to uphold — can keep his two law enforcement jobs. The reasoning: The crime occurred while he was off-duty and had nothing to do with his positions as a sheriff's officer or part-time officer in Frenchtown.

It's preposterous. This wasn't a speeding ticket. Hupka pleaded guilty to molesting a woman while she was asleep or passed out from alcohol, and there is evidence he might have done much more than that.

Hupka originally denied having sex with the victim, but changed his story and said he touched her private parts for personal gratification. Important details were omitted when he was allowed to cop the plea, however: After the assault, the victim, after finding she had been sexually violated, discovered she was pregnant. A DNA test established there was a 99.9 percent probability Hupka was the father, according to the pre-sentence report.

As we all learned in sixth grade: Women don't get pregnant from "touching."

Even though Hupka resigned as part of his plea, his attorney argued the state's dismissal statute only applies when there is a direct link between the offense and the job, and in a 3-2 decision, the court agreed. But that ruling is morally flawed.

We agree with dissenting Justice Stuart Rabner, who said the aim of the forfeiture statute is “to bar those who have once violated the public trust from (having) a second opportunity.” The majority missed another point: The law is designed to protect the public, not the offender.

The court’s ruling, however, tells law enforcement officers they can violate serious laws and keep their paycheck. And the insistence that there’s no link to Hupka’s job is silly: To be effective, cops must enforce and obey the law. Who wants Hupka investigating a sex crime, or trusts him anywhere near a female victim?

The law should be changed. Now. Taxpayers shouldn’t be forced to keep sex offenders or other felons on the payroll.