Earlier quoted context omitted.
Japan, in a way, is a great counter example. As a gajin, no matter if tourist or foreign resident, you will never grasp the nuances of Japanese culture in detail. But you don't have to. You just need to understand and respect the basics. Be polite, respect customs, take your shoes of, when appropriate and you will feel welcome. It may be a lot harder if you live there and you'll probably never be really accepted. But…
I don't know much about Japanese culture, but I've heard some bars / restaurants don't even allow foreigners to enter, so I agree with your premise that being accepted depends on the culture. From what I've observed in Latin America, lots of foreigners commit big cultural faux pas without even realizing it. The standard American way of closing a car door is considered extremely rude in Colombia. Most foreigners leave…
That's true. From my experience for two reasons:
Either they really don't want foreigners in their place. For example: in a hostess bar that caters to Japanese salary men you are not welcome as a foreigner. The other reason is that they are afraid that they could offend you by not living up to your expectations, since they assume that you're unable to make yourself understood, and that they could lose face in the process since they won't make you happy.
You're porobably not interested in establishments that don't want to cater to you. And if option B happens then you just thank them, bid good bye and find some other place. What you don't do is raise a stink. That would embarass everybody, be unhelpful and lead nowhere.
There's a plus side to the hard communication part too. That's if you're adventurous and eat everything:
You go into any restaurant that catches your fancy (and it's hard to find a bad place just about anywhere in Japan. Frankly, it never happened to me) indicate that you want to eat and probably frighten them.
Then what you do is smile at the chef and announce: Omakase![1] (literally: I leave it up to you).
After he serves you something (which is usually incredible tasting food) you get to the most important part: You take a few bites, small at the chef and announce: Oishi! (delicious) You can repeat this a few times during your meal.
See, the chef is afraid that he could disappoint you and when you signal how much you like it you make him a very happy person. You may leave the place as a friend and he will be delighted when you return.
What you should never do is asking to exchange things on the menu. That's extremely confusing and very uncommon. If there's anything you can't eat it's a good idea to have a note in Japanese that you can show him.
All those tips are thanks to HNer Mike Charter[2], who wrote some incredible useful tips about Japan (he's a Canadian living there for a long time) and unfortunately stopped posting.
So to cut back to your statement: Yes, there are racist and xenophobic places and people in Japan. But it's not always what it seems. And if your curious and accept things which seem peculiar to us you can experience unbelievable awesomeness in Japan.
[1] https://en.wikipedia.org/wiki/Omakase [2] https://news.ycombinator.com/user?id=mikekchar