Japan also still virtually has no legal protection against this kind of stuff, discrimination of that type is often not being prevented.
That said a lot of the younger Japanese don't share these attitudes. Large cities are more diverse than they were 20 years ago.
It seems to me nobody has any problem with you if you make a minimal attempt at speaking using Japanese (most of them don't understand English at all and that puts them "on the spot", and while you can find some who are adept at Spanish and Italian and other languages you'd never expect, by raw statistics you aren't going to meet one of those in the streets if you are asking for directions or something). They seem to be pretty reasonable about it if you suck or make mistakes, but they seem to really value the effort.
About the bars, I never pried too much, but I was told it was Yakuza hangouts and I probably don't want to go in there anyway. I don't think locals are welcomed either. Not sure if they were messing with me or not, but to be honest they didn't look like a place I would have fun into if I was magically accepted. None of the actually fun places seemed to have an issue having me or my colleagues as patrons.
I have far more people checking me out while shopping like if I was a shoplifter, giving me weird looks, troubling me with paperwork and rent, trying to charge me more in restaurants or shops, and generally making me feel unwelcomed when I am in Spain. And I was born there! (I did lose the accent and I don't look very "typical" so they think I'm British or American).
I never understood why Japan of all places is so demonized online. It's far, FAR from a perfect country, but most people just do their non-outrageous, boring life things. There are no used panties vending machines littering the streets, not everyone is obsessed with cute things, there are no child wives everywhere and there are no game shows where guys fuck their female relatives. With every other country there are at least people calling this stuff out, but when it's Japan everyone just accepts the fabricated or misunderstood article at face value and goes "oh Japan you are so wacky/xenophobic" or even "Two nukes weren't enough" (I swear this comes up more often than it's comfortable, I'm not making this up).
If anything I get the impression that people is very racist against Japan.