Iron golems can spawn inside solid blocks. Best way to reproduce place 5 villagers under a 7 x 7 room. Make that 7 x 7 area the only place they can spawn. by adding walls on top of a solid block wall all the way around with a single water source block in the center on the floor of the spawn chamber. Screen shots will provide layout.
Thank you for your report!
We're tracking this issue in MC-189332, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki