The son of a Taiwanese celebrity couple will be released from federal custody and deported, nine months after he threatened to carry out a shooting at the Delaware County high school where he was studying as a foreign exchange student.

During a hearing Monday in federal court in Philadelphia, An-Tso "Edward" Sun – 18-year-old son of the actors Peng Sun and Di Ying – described his March threat to attack Monsignor Bonner and Archbishop Prendergast Catholic High School in Drexel Hill as an immature joke and said he never had any intention of acting upon it.  He apologized for the trouble he had caused his parents, the United States, and his native country.

But U.S. District Judge Nitza Quinones-Alejandro interrupted.

"The word is not trouble for what you've brought to your family," she said. "You have brought them shame, which is an even higher offense."

The "time served" sentence Quinones-Alejandro eventually imposed – with stipulations for the younger Sun's voluntary and immediate deportation – brought to an end a legal drama that has received only moderate attention in this country but has driven sensational, front-page headlines in the island nation for months.

Since his arrest earlier this year, Tawianese news outlets have tracked Sun's parents as they put their film careers on hold and decamped nearly full-time to the United States to be closer to their son at the federal detention center in Philadelphia. Some even reported that the couple had placed homes worth millions of dollars on the market to fund his defense.

Each of Sun's court appearances — first to plead guilty in June to state counts of making terroristic threats in Delaware County, then in August to do the same for federal ammunition possession charges – have attracted a reliable crowd of paparazzi and television news crews from overseas.

Up until Monday, his parents had stayed away from court, fearing that their presence might cause a distraction, his lawyer Robert Keller said. "The Taiwanese press has been all over this," he said. "The entire country knows what he's done."

Peng Sun, who has starred in more than a dozen movies, pleaded Monday for mercy for his son. Addressing the court while dressed in a dark suit and tie, he described the strain that concern over his son's fate had placed on his career.

"My job is to entertain the public," he said through an interpreter. "Even when I go to work, I cannot perform the best."

Other friends described the younger Sun as naïve and sheltered, brought up in his parents' world of celebrity excess. He came to the United States as a foreign exchange student in 2017, they said, and was set to attend Temple University this fall to pursue a dream of becoming a forensic scientist.

Yet within months of his arrival, Sun began visiting gun ranges, where he fired assault rifles and semiautomatic weapons and began stockpiling ammunition, which is illegal for foreign visitors to purchase in the United States.

On Monday, Keller described his client's fascination with guns as that of a sportsman.

But when Sun told a classmate not to show up to class one day in March because he intended to "shoot up" the school – a comment he immediately dismissed as a joke – school officials were in no mood to laugh. The threat came just a month after a gunman killed 17 students and staff and injured others at Marjory Stoneman Douglas High School in Parkland, Fla.

Bonner-Prendergast officials contacted authorities, and investigators later discovered 1,600 rounds of ammunition, several weapons, a military-style ballistic vest, and a high-powered crossbow in Sun's bedroom at his host family's house in Lansdowne.

On his school-issued iPad, investigators discovered searches for how to buy an AK-47 or an AR-15 semi-automatic rifle.

"It is impossible to know whether the defendant intended to carry out that horrific threat [but] simply by making it, [he] instilled tremendous fear in the minds of other student[s]," Assistant U.S. Attorney Sarah Wolfe last week argued in court papers, seeking up to an additional 21 months of prison time.

Quinones-Alejandro rebuffed that request Monday. But as she prepared to send Sun and his family back home to Taiwan, she paused to address his parents, seated together in the court's second row, holding hands.

"Once your son is released, I want you to make sure your son grows up and becomes a mature person," she said. "You can't continue to shelter him."