SHANGHAI -- The U.S. Supreme Court ruling on gay marriage has aroused significant debate in China -- a country where, while homosexuality was decriminalized in 1997, and is increasingly accepted among young people, gay rights still receives relatively little in-depth discussion.

Observers say the fact that Justice Anthony M. Kennedy quoted Confucius in his final summing up of the Supreme Court's debate -- noting that the ancient Chinese philosopher, whose thought underpins many of China's cultural values, “taught that marriage lies at the foundation of government” -- gave Chinese media a reason, or even an excuse, to report in detail on the ruling. And this was quickly followed by a heated debate online, with some posts on the topic getting millions of hits.

Some commenters emphasized that -- as Kennedy noted in his statement -- Confucius had thought of marriage as between a man and a woman, and stressed that Confucian scholars saw having children as a person’s duty, in order to continue the family line. Nevertheless, gay activists welcomed the rare discussion:

“I’ve never seen so much debate in both the traditional media and social media – so many people, and in so much depth,” Ah Qiang, director of Guangzhou-based Parents and Friends of Lesbians and Gays (PFLAG) China, which campaigns for gay rights, told International Business Times. “In the past when smaller countries passed these bills, there wasn’t so much reaction. But Chinese people are especially interested in the U.S. -- so many Chinese people are travelling there now, or moving there to work. So now they have to face up to this issue.”

And some experts said the ruling could have a significant impact in China, coming at a timely moment when gays in the country are becoming more outspoken -- yet the government is also pushing back against many aspects of growing social openness:

"The US ruling … will be a boost for the gay rights movement here. I've noticed that there are more heterosexuals who support [gay marriage]," sexologist Li Yinhe, who has regularly -- and forlornly -- proposed bills legalizing gay marriage to China’s legislature, told Monday’s Global Times.

At the same time there was also angry criticism in the Chinese media: Shanghai-based news website The Paper published articles by several philosophers, including Prof. Zeng Yi of Tongji University, who described the U.S. decision to approve gay marriage as a "crime against humanity," and stressed that the purpose of marriage was to have children.

Activist Ah Qiang said the level of critical comment was also unusual: in the past he said, “people who opposed homosexuality rarely felt a need to speak out -- but they’ve taken this chance to express their feelings. I think the U.S. decision was a shock to them -- that a country with so much religious opposition to gay marriage passed the bill -- so they feel threatened.”

A reminder of why those opposed to homosexuality in China are becoming increasingly alarmed was provided by some of China’s biggest companies -- more than a dozen companies, including e-commerce giant Taobao, and Uber-equivalent Didi Dache, added the gay-pride rainbow flag to their websites this weekend in response to the ruling.

Activists say Internet companies have led the way in promoting tolerance for homosexuality, in a country where it still remains taboo in many sectors of society -- and where the majority of gay people not only don’t tell their families about their orientation, but have also felt it necessary to marry members of the opposite sex and have children, in order to conform to social mores.

This year Taobao -- owned by New York-listed Alibaba -- held a Valentine’s Day competition for gay couples to tell their love stories, with those who attracted most public support being flown to West Hollywood to hold their wedding ceremonies.

PFLAG China’s Ah Qiang said the support of such companies was a “very positive step,” and he said the Internet in general had contributed to more open attitudes among China’s younger generation. As a result of such changes he said, the number of young gay people in China’s cities who felt they had to get married to a member of the opposite sex to please their families or society was “declining sharply. More and more young people have read about how people live in other countries, and have seen there’s a new way – that you can marry someone of the same sex.”

Yet while Ah Qiang also suggested that China had less deep-rooted religious opposition to gay marriage than many Western countries, he estimated that about 60 percent of gay people in China's big cities are still marrying members of the opposite sex, and as many as 90 percent of gay people in China’s more traditional hinterland are doing the same. And he suggested it could be two decades before gay marriage might be a serious possibility in China.

And in a sign of the continuing challenges to the acceptance of gay marriage, a commentary in the official Global Times newspaper said that the U.S. ruling showed that "Society needs to show increasing tolerance for gay marriage, but it's unnecessary to hype it up to induce potential homosexuals." It added that "heterosexual marriage conforms more to the laws of nature and the purpose of marriage," and concluded "we should send our best wishes to the homosexuals but meanwhile hope that some traditions of human beings will continue."