@OmegaGay Hmmm... I have noticed that people seem to equate racism and xenophobia... this is a problem. Xenophobia is (literally) "fear of the strange, alien or foreign". Racism is "a believe that race determines the majority of human traits and [generally] that your own race is inately superior to others".
Japan is indeed highly xenophobic but is also the (non-city-state) country in the world with the least crime so you can see how they would naturally fear things that were not Japanese. It doesn't help that USAian military personal stationed in Japan (some would say "occupying" - given the size and number of USAian bases in Okinawa that is actually a debatable point) are responsible for a good chunk of the most visible and media friendly crimes (rape, including child rape) and that few are successfully procescuted in Japan (you can count them on one hand) and prosecutions in the USAian military system amount to less than a quarter with most receiving no jail time - they generally return to base before they are caught by the Japanese police and are then transfered out of Japan by the USAian military on USAian military transport and never allowed to enter Japanese custody despite requests otherwise. Two particularly egregious cases even led to the removal of some USAian military bases, renegotiansions of various important bi-lateral and defense agreements between the USA and Japan due to the awful history of this problem - it dates back to the admitted occupation by the USA after WWII. In both those cases the at least one of the offending parties commited or attempted to commit rape again in the USA and received a much more severe punishment there than had been allowed the Japanese system due to pressure from the USAian government. THAT is racism... the USA thinking that Japanese (children's) lives do not matter as much as USAian (children's) lives.
The irony is that even down to the smallest things many foreigners in Japan do not respect the culture and customs here and cause people to fear the repercussions of their actions - garbage disposal has been a serious issue in Japan for it's entire history - it has almost zero natural resources, no oil, gas, mineral deposits etc. to speak of. This means almost all of this has to be imported or recycled increasing costs and the difficulty of manufacture. Outside of Europe most countries still do not take this matter as seriously as Japan and even in Europe only about half as vociferous. This leads to many foreigners applying their own countries rules to garbage i.e. everything in one bag. Unfortunately standard non-recyclable garbage should be split into burnable and non-burnable since most of the burnable is incinerated for power to avoid having to import so much expensive and environmentally-unfriendly gas and oil. So dumping non-burnable stuff into the standard burnable bin (usually the default) clogs up the incinerators that produce power - this causes a number of expensive problems. Failing to abide by rules for garbage disposal here also brings problems for local residents as the garbage collectors will refuse to accept garbage if they notice it is incorrectly sorted, but then it is up to the local residents association to find the culprit and correct the problem - this is both difficult and highly embarressing for all Japanese people involved, something made worse when they have trouble communicating the problem to an offending foreigner compounded by the fact foreigners often aggressively brush off the issue rather than be embarressed and apologetic as a Japanese person would almost always be. This aggressive behaviour in the face of breaking rules that have serious consequences; local, prefectural and national, makes many Japanese who (in the cheap areas where many younger foreigners often live) have not been abroad or have only little experience with foreigners makes them, understandly, fearful of foreigners.
Many people will argue that Japan's xenophobia is primarily directed towards Westerners or non-East Asians... that is because the Japanese themselves can not easily identify non-Japanese East Asians with sufficient certainty without lots of practice, especially since other East Asians often make many fewer cultural or social mistakes and often dress much as the Japanese do. However the approbrium they can receive if "discovered" is rather worse as some Japanese will consider them as purposfully hiding their otherness and take this as an offense. Given that China is a neighbour you maybe understand this worry of "hiding" Chinese agents, especially given the number of times Japanese and Chinese forces have clashed over teritorial claims, nevermind anything else.
https://www.theguardian.com/world/2014/feb/09/sexual-assaults-us-military-japan-prison-unlikely
https://en.wikipedia.org/wiki/Michael_Brown_Okinawa_assault_incident
https://en.wikipedia.org/wiki/1995_Okinawa_rape_incident