Tokyo (CNN) "Even though we live in different places, we live under the same sky," read the stanza on the sides of boxes filled with face masks and thermometers sent to China from the Japan Youth Development Association (JYDA).

Over 1,300 years ago, a grandson of the Japanese emperor sent that ancient poem to a high-ranking Chinese monk called Ganjin. It inspired him to go to Japan to spread Buddhism.

Just as it did then, the poem hit home today, going viral on Weibo with more than 39,000 posts tagging the line. Even former Japanese Prime Minister Yukio Hatoyama shared it with his Twitter followers.

The Japan Youth Association wanted to find a message that communicated their vision of bridging the divide between people when sending aid to China. They thought an ancient poem did that best.

As China battles the coronavirus outbreak that has so far killed more than 2,700 people and infected over 80,000, Japan has proved to be something of an ally. Earlier this month, China's foreign ministry spokesperson Geng Shuang lauded Japan for supporting China.

By contrast, Geng accused the United States of overreacting and spreading fear by being the first to evacuate personnel from its consulate in Wuhan and imposing a travel ban on Chinese travelers.

The poem signified a thawing in relations between the old enemies that can be traced back to Japanese Prime Minister Shinzo Abe's state visit to Beijing in 2018.

As Tokyo and Beijing stress that the state visit of Chinese leader Xi Jinping to Japan in April will not be canceled amid the coronavirus outbreak, a renewed focus is on how the world's second and third-largest economies could deepen ties.

Changing Chinese attitudes

Bitter territorial disputes and long-running grievances dating back to World War II have marred the Japan-China relationship for decades.

During WWII, the Japanese Imperial Army was responsible for a 1937 campaign of rape, murder and looting that became known as the Nanjing Massacre, in which an estimated 300,000 people died. Japanese air strikes during the war also inflicted severe damage on Chinese civilians in Chongqing, killing an estimated 32,000 people between February 1938 and August 1943.

China and Japan have often argued over how the past should be remembered.

Successive Japanese governments have apologized, with some prime ministers personally expressing regret for Japan's actions in the war, but many Chinese believe Japan has not adequately acknowledged the extent of its brutal occupation of the country during WWII.

Tensions flared in 2013, when the standoff over the disputed Diaoyu/Senkaku islands in the East China Sea inflamed nationalistic sentiment on both sides and impaired economic ties.

Back then, 92.8% of Chinese citizens surveyed had a negative impression of Japan, according to Japanese non-profit Genron, which conducts an annual poll on Japanese and Chinese relations.

By 2019, however, the number of Chinese people with "negative impressions" about Japan had almost halved to 52.8%.

That follows Abe's attempts to warm relations with Chinese President Xi Jinping, with repeated invitations for talks aimed at restoring bilateral relations after the disputed island tensions. The two finally met at APEC in 2014 and shook hands in front of the world's cameras.

"This is the first step towards the improvement of the bilateral relationship based on the principle of the strategic mutually-beneficial relationship," Abe said after the meeting.

As political relations improved, Chinese tourists starting booking trips to Japan and forming their own, positive views on Japanese culture, according to Yasushi Kudo, president of Genron. In 2018, 8.38 million Chinese visited Japan, up sixfold from 2013, according to Genron. Chinese consumers are also watching Japanese anime on video streaming platforms like Bilibili, which has roughly 37.6 million daily users, finding information on Japan on social media rather than on domestic news sites.

But while Chinese millennials with greater purchasing power are traveling more, the same can't be said of Japan, said Kudo. As the Japanese economy shrinks and millennials face issues such as the aging population and static salaries, there is less desire to explore the world, according to Kudo.

"You create an impression of another country by going there and making friends, but Japanese people aren't going to China that much, so they're forming their opinions based off of Japanese media reports," said Kudo.

Japan Youth Development Association staff pack emergency medical supplies. They had to send the boxes in three batches as the post offices were inundated with supplies being sent to China.

Nevertheless, Japan is trying to make big-spending Chinese tourists feel welcome, erecting signs in Mandarin in Tokyo and broadcasting announcements in Chinese at train stations.

For Shuichi Kato, whose Kyoto-based tourist organization sent 15,000 face masks to China, Hong Kong and Taiwan, visitors from these countries are a lifeline for his business. "Our region flourished as an international sight-seeing region because of our Asian friends," said Kato.

By February 18, Japan's private sector had donated over 3 million masks as well as 43.96 million yuan ($6.3 million) in monetary donations.

On a state level, things have been improving, too.

A 'marriage of convenience'

Nothing brings together two old foes like a common problem.

That was the case in May 2018, when Xi and Abe held telephone talks in a historic first to discuss the denuclearization of the Korean Peninsula. A few months later, Abe became the first Japanese leader in nearly seven years to visit China when he made a state visit to Beijing.

Then, China and Japan held their first forum geared to strengthen their collaborations in third-party countries such as Thailand, which has friendly diplomatic relations with both Beijing and Tokyo. By the end, both countries had inked agreements worth $18 billion.

More recently, the rapprochement between China and Japan has had a lot to do with Trump's declaration of a trade war on China and Japan, according to Koichi Nakano, a political science professor at Sophia University.

"Before Trump's arrival, Xi and Abe didn't have such a good relationship, now their relations are more a marriage of convenience in face of the common threat," said Nakano.

But while Abe's support for China as it battles the coronavirus outbreak may have won him some mileage with Xi, it has sparked anger among his hawkish supporters at home, as Japan steps up efforts to contain its own outbreak.

"The Japanese government has taken relative soft stance when it comes to blocking the flow of people from China to Japan compared to some other countries," said Nakano. "Some of Abe's supporters were angry about that as they thought he prioritized his new friendship with Xi over national security."

Focusing on the positives

Despite this recent uptick in relations, fundamentally, Japan and China have rivaling visions for the future of the Asia-Pacific region and the role of China within it. Issues over territory have not gone away, but merely been placed on the back burner.

"The political elites have spent the decades vilifying either side to rally their troops behind the leaders, it would be naive to think that trend would change now," Nakano said.

Over the past few years, China has bolstered its naval powers in the South China Sea at a speed unmatched by any nation. In response, Japan announced in 2019 that it would allocate more resources to defend its territory from possible Chinese incursion.

While Japan needs to do business with China, it's not willing to sacrifice the umbrella of US military protection, and has already built up other allegiances across the region to counter a rising China, said Jeff Kingston, a Japan expert at Temple University.

"For now, both sides see an advantage in dialing down tensions. Some of the permafrost has thawed but there are still deep layers of frost -- and that's not just about territory, there is also historical differences," he said.

Compared to a century ago, China and Japan are now both highly modernized, globally significant economies, meaning any potential downturn in their relations could have serious ramifications globally.

With a looming global economic slump and racist coronavirus-related assaults and slurs spreading faster than the outbreak, for now, China and Japan appear to be focusing on what they share in common and what benefits both parties.

"The recent outbreak has been a stress-test for bilateral relations, so taking what is anxiety-inducing and turning it around was clever," said Kingston. "That poem is trying to get people to listen to the better part of themselves."