A California appellate court Tuesday found unconstitutional a first-of-its-kind law mandating prosecutors, not secret grand juries, charge police officers with a crime in a fatal shooting while on duty.

The law was hailed by defense attorneys and social rights activists when it was adopted in August 2015, reports said Tuesday. But the legislation was contested by state prosecutors who said it tied their hands in efforts to investigate incidents by limiting the grand jury's power.

The law requiring district attorneys to charge officers was created in response to secret grand juries failing to indict officers in the killings of Michael Brown in Ferguson, Missouri, on Aug. 9, 2014, and Eric Garner in Staten Island, New York, on July 17, 2014.

The decision preserves the prosecutors' prerogative of filing charges or submitting criminal cases to grand juries. This procedure differs from that under the U.S. Constitution that necessitates an indictment to come from a grand jury unless the defendant waives that right.

“The Legislature does not have the power to enact a statute that limits the constitutional power of a criminal grand jury to indict any adult accused of a criminal offense,” Justice M. Kathlees Butz of California's 3rd District Court Of Appeals, told the San Francisco Chronicle.

Democratic state Sen. Holly Mitchell of Los Angeles, the author of the original bill, said it had been created to establish trust between community members and the officers patrolling them. She said the current state of the U.S. criminal justice system “lacks transparency” because secret juries enable prosecutors to sidestep making public decisions on controversial police killings.

The law had been challenged by El Dorado County District Attorney Vern Pierson in January 2016, who told local reporters: “The grand jury is a tool to get to the truth.” It had been originally created following a police killing of an unarmed man at a motel in June 2015 in Lake Tahoe, California. Police were dispatched to the motel after receiving a tip about domestic violence there. One officer fatally shot Kris Jackson, 22, while Jackson was trying to escape out a bathroom window.

The review of the shooting is still under review.

The officer, whose name has not been released, told investigators he fired the fatal shot because he thought Jackson, whom he recognized as a gang member from a prior incident, had a gun.

There were 963 Americans who were shot and killed by police while on duty in 2016, the Washington Post reported.

Of the roughly 1,100 people killed by police in the U.S. in 2015, 15 of those officers were charged with murder or manslaughter, CNN reported on Dec. 5, 2015.