Yes, it works beautifully because there are literally no bloody assholes uncivilized enough to be thieves.
Vending machines are abundant for the same reason: There simply aren't any assholes fucking uncivilized enough to loot or otherwise damage/destroy them. The supremely civilized culture of Japan manifests in superb security and all the good things that are only possible in such an environment.
You leave a vending machine outside somewhere in the United States of America? Son, that thing is going to get freedom'd faster than the US military goes bombing deserts for oil. I say that as an American and yes it is fucking shameful, but that is the state of affairs.
As an aside, Japan really likes the warm glow of a vending machine at night: Dutifully serving its customers without complaining and lighting the way; some of them come with features to remember repeat customers and their preferences, recommend products based on their expressions, and some still might even make small talk. Yes, Japan loves vending machines.