I think Japan is well aware it couldn't feed the whole island chain even if it absolutely needed to, but it also has a robust domestic manufacturing and high tech industrial exporting sector which continually acquires funds for foreign currency and food. Totally unlike Sri Lanka.
To put it crudely Japan doesn't need to grow all its own food because people send it money for Toyotas and Mitsubishi cargo trucks and such, and it uses that to buy whatever food it wants.
https://www.macrotrends.net/countries/LKA/sri-lanka/populati...
Japan imports about 60% of its food.
https://www.merlofarminggroup.com/agri-view-japan%E2%80%99s-...