The end might be in sight: Roman Polanski, the Oscar-winning filmmaker and fugitive from California justice, must wait a little longer before he learns whether he can put his underage sex conviction behind him and return to the U.S. without being jailed.

Following a motions hearing Monday in Los Angeles in the 40-year-old case, Superior Court Judge Scott Gordon told Los Angeles deputy district attorney Michele Hanisee and Polanski's attorney, Harland Braun, that he will issue a written ruling later on Polanski's latest legal effort to end the case.

Gordon gave no indication about how he would rule but said he thought Braun's allegations that previous judges had mistreated the director warranted a full hearing. A written ruling could come within three months.

Media at the packed hearing reported Gordon seemed skeptical of Braun's arguments, and he noted that many of the issues raised during the 45 minutes of arguments had been litigated before, according to Varietyand Deadline.com.

The case dates from 1977 when Polanski was accused of statutory rape for having sex with a 13-year-old girl after giving her champagne and a sedative. He spent time in jail, then pleaded guilty in a plea bargain. He fled the country in 1978 after becoming convinced the judge in the case, now deceased, planned to renege and sentence him to a lengthy prison sentence. (The accuser, now in her 50s, has since forgiven Polanski and says the case should end.)

In the decades that followed, the Polish-born Polanski, 83, has been unable to return to the U.S., his travel restricted to France, where he lives, Switzerland and Poland. All three countries have rejected U.S. requests to extradite Polanski, although he spent nearly a year in jail or house arrest during the Swiss proceedings.

Braun argued at the hearing that Gordon should give some indication of how Polanski would be sentenced if he returned to Los Angeles. Polanski wants prosecutors and Gordon to honor the original plea bargain, including the alleged promise not to sentence Polanski to additional time. Hanisee refused and Gordon didn't say how he would respond.

However, Gordon noted that the original plea agreement did not contain a promise of a particular sentence. Gordon also questioned Braun’s argument that the Polish Supreme Court’s decision should have a bearing on a California court. The Polish decision, issued in 2015, raised questions about "the integrity and honesty of many of the judges" involved in the case over the decades, Braun said.

The Los Angeles district attorney's office, which has doggedly pursued Polanski over the years, still wants to put him in prison. Hanisee argued that Polanski needed to appear in court to resolve the charges and urged the judge to reject what she called an attempt by a “wealthy celebrity” to negotiate his sentence from afar, according to The Associated Press.

“Mr. Polanski is asking this court to completely abandon all legal principles and give him special treatment,” Hanisee said.

Polanski's legal troubles have not hurt his career in Hollywood despite his inability to actually travel to Hollywood: He won the Oscar for best director for his 2002 film The Pianist and was nominated for 1979's Tess. (He also was nominated before the case, for 1974's Chinatown.)