SAN FRANCISCO — A federal judge Tuesday ruled that a California law barring IMDb from publishing actors' ages violates the First Amendment, and said the statute also fails to address a deeper problem of sex discrimination in Hollywood.

In an order granting IMDb's motion for summary judgment against Assembly Bill 1687, U.S. District Judge Vince Chhabria of the Northern District of California wrote the law is a “direct restriction” on factual speech. He also wrote the law is “not narrowly tailored” or “actually necessary” to combat age discrimination against older actors.

Adding that while that is “more than enough to strike it down,” Chhabria went on to chide the state and supporters of the law for implementing a poor fix to a problem of discrimination against women in the entertainment industry.

“The legislative materials repeatedly cite an article discussing '[t]he commonplace practice of casting a much younger female against a much older male' and lamenting the significant under-representation of women in leading roles and in directors' chairs,” Chhabria wrote. “The defendants describe this as a problem of 'age discrimination.'”

The judge continued: “While that may be accurate on some level, at root it is far more a problem of sex discrimination. Movie producers don't typically refuse to cast an actor as a leading man because he's too old for the leading woman; it is the prospective leading woman who can't get the part unless she's much younger than the leading man.”

He called this a “manifestation of the industry's insistence on objectifying women, overvaluing their looks while devaluing everything else.”

The defendants in the case — the California Attorney General's Office and the Screen Actors Guild-American Federation of Television and Radio Artists (SAG-AFTRA) — “barely acknowledge this, much less explain how a law preventing one company from posting age-related information on one website could discourage the entertainment industry from continuing to objectify and devalue women,” the judge concluded.

SAG-AFTRA did not immediately respond to messages seeking comment. The AG's office said in an email it is still reviewing the judge's order.

Chhabria previously granted a preliminary injunction blocking enforcement of the law while the lawsuit was ongoing. He also excoriated the California Attorney General's Office for making harassing discovery requests in the lawsuit.

IMDb is represented in the case by John Hueston of Hueston Hennigan. A spokeswoman said the law firm declined to comment on the ruling.