In the third of a series on Japan's population crisis, the BBC's Philippa Fogarty looks at whether migrant workers could help solve an imminent labour shortage.

Flavia, a university student, has lived in Japan since she was nine

When Flavia was 10, a teacher at her primary school told her she had no future in Japan.

She had been in the country for a year and was struggling to get to grips with the language.

She remembers the teacher telling her: "You'll never speak Japanese like the Japanese, and you can't keep up. Why don't you go to a Brazilian school? Or back to Brazil?"

Eight years later, when she told him she had been accepted into a top Tokyo university, he could not conceal his shock.

Japan is not big on diversity. Foreign residents make up only 1.6% of the population and successive governments have opposed allowing migrants in, fearing they could create social tensions.

But in 1990, facing a labour shortage, the government came up with a compromise. It would allow second and third-generation Nikkeijin - "people of Japanese origin" - to come to Japan as permanent workers.

Nikkeijin had Japanese blood, the case went, and would speak Japanese, understand the culture and integrate more easily.

Flavia's paternal grandparents were some of the tens of thousands of Japanese nationals who emigrated to South America in the early 20th Century to work on plantations.

When the doors opened, many South American Nikkeijin thronged to Japan. Brazilians are now Japan's third largest group of foreign residents, behind ethnic Koreans and Chinese.

And how Flavia and her fellow Nikkeijin integrate is something that is being watched very closely.

"The introduction of Nikkeijin has been seen as a sort of test case by the government, in terms of how to introduce large numbers of foreign workers in the future," says Dr Yoko Sellek, of Britain's White Rose East Asia Centre.

"The country is ageing and so the government has to think about introducing unskilled workers," she says. "But it sees the problems in the Nikkeijin community as warning signs."

For the newcomers are a lot less Japanese than the government expected. Second and third generation Nikkeijin are sociologically Brazilian, they speak Portuguese and most of their cultural references are Brazilian.

'Brazilian equals bad'

Hamamatsu City, an industrial base about 300km south of Tokyo, is home to the largest number of Brazilians. Almost 19,000 have settled there and found jobs in factories.

The city needs them, says local government official Keiko Murakami, because they are doing the work that young Japanese people do not want to do.

So officials have worked to help them by providing language programmes, translating key documents and employing interpreters to help people navigate administrative issues.

There are many signs of the Brazilian presence in Hamamatsu

On the streets, buildings are signposted in Portuguese. South of the station, Portuguese-language billboards offer driving lessons and bank loans, while shops sell Brazilian DVDs. On the surface, Hamamatsu appears to be embracing its new arrivals.

But rows over things like loud music, parking spaces and rubbish are daily causes of friction. "Their culture and customs are different," says Ms Murakami. "Japan has various rules and they don't know the rules, so this leads to tensions."

One serious problem, she says, is education. Integrating older Brazilian children into the classroom has proved difficult.

While 98% of Japanese children complete high school, the percentage is far lower for the newcomers. Many drop out of middle school too, because they cannot communicate and are often bullied.

This drop-out rate has been linked to high levels of juvenile crime, which in turn has created negative perceptions of the Brazilian community.

Yes, says Flavia, many of her friends have been in trouble for stealing cars. But this is partly because they have been alienated by prejudice and a lack of decent options for education and employment.

Many of the newcomers struggle to adapt to the Japanese schools

"Some of my friends came to Japan aged about 15 and they knew nothing, no Japanese. So they were discriminated against and had to go and work in a factory. It was really hard for them," she says.

"And if people keep telling them, 'You're Brazilian so you're bad', they will do these things."

For workers, meanwhile, low wages and exploitation remain a problem. At the factory where Flavia's father works, he misses out on bonuses and benefits paid to his Japanese co-workers and, after more than a decade of full-time work, has only just received his first days of paid holiday.

In Brazil, he graduated from university and his wife was a teacher. But making the leap to a white collar job is out of the question.

"The Japanese need us but they still discriminate against us," says Flavia. "They say: 'We have the same blood but you're different, so go and work in a factory'. Japanese people don't think we can work alongside them, wearing suits."

'Unresolved issues'

Of course, not all of Flavia's experiences have been bad - some people did go out of their way to help her, she says.

Ms Murakami believes that most Japanese now accept that they will have to live alongside foreigners.

The majority of experts agree, however, that immigration is not the answer to the population crisis because of the numbers involved - some 650,000 annually to maintain the population at its 2006 peak, according to a government report.

Dr Sellek says the government is far more likely to modify current immigration policy - importing more short-term "trainees" from Asia, targeting skilled workers like Philippine carers - than to throw open Japan's doors.

But the Nikkeijin will remain a hot topic.

"If we don't work out the unresolved issues with the Nikkeijin community, then how can we think about taking more?" says Ms Murakami.

"We can't move on to the next stage of the debate until these problems are solved."