LOS ANGELES (AP) — A California law that sought to prevent age discrimination in the entertainment industry by blocking a popular Hollywood website from posting the ages of actors was struck down Tuesday as unconstitutional.

U.S. District Court Judge Vince Chhabria in San Francisco said the law passed in 2016 violated the First Amendment rights of IMDb.com by preventing it from publishing factual information on its website that provides information about movies, television shows and their casts and crews.

ADVERTISEMENT

The law was a “direct restriction on speech” and was flawed because it was not narrowly tailored and was “underinclusive” by targeting IMDb, Chhabria said.

The ruling comes as sexual misconduct scandals that erupted in Hollywood last fall and spread more broadly have also brought new attention to pay disparity and other gender-related discrimination in the entertainment industry. Without referencing the #MeToo movement, the judge said the law was misguided because it sought to prevent discrimination of actors who couldn’t get parts because of age bias when a bigger problem was sex discrimination.

Materials supporting the law referred to the practice of casting younger women against much older men and also to the lack of women in leading roles and as directors, the judge said.

“This is not so much because the entertainment industry has a problem with older people per se,” Chhabria wrote. “Rather, it’s a manifestation of the industry’s insistence on objectifying women, overvaluing their looks while devaluing everything else.”

Supporters of AB 1687 said it was necessary because existing laws were not enough to eliminate age discrimination and older actors were concerned that they would be shut out roles. The law was defended by the state attorney general and Screen Actors Guild-American Federation of Television and Radio Artists.

SAG-AFTRA had argued it was OK to ban publishing the ages of actors and other entertainment professionals because those facts facilitated age discrimination. Chhabria noted that was “an argument that, if successful, would enable states to forbid publication of virtually any fact.”

The union said it was extremely disappointed with the ruling and would appeal.

“The court unfortunately fails to understand or recognize the massive impact gender and age discrimination has on all working performers,” said Duncan Crabtree-Ireland, general counsel of SAG-AFTRA. “That discrimination is facilitated by IMDb’s insistence on publishing performers’ age information without their consent.”

ADVERTISEMENT

Chhabria had temporarily halted the law from taking effect last year while he heard further arguments in the case.

IMDb, also known as the Internet Movie Database, had argued it shared the goal of preventing age discrimination, but the law would fail to achieve that and instead would “chill free speech and undermine public access to factual information.”

Representatives of the lawmaker who authored the bill, the attorney general who defended it or the entertainment website that challenged the law did not immediately provide comment requested by The Associated Press.