First, you only 90 days-actually a bit less-to stay in the EU.
I dont know enough to know if this is true.
90 days including partial days is the limit for Schengen, not the EU. Ireland and Cyprus are in the EU but is not in Schengen. What I dont know is if they have an agreement with Schengen that may affect your stay. Liechtenstein, Norway and Switzerland are in the Schengen area but are not EU member states.
You can't stay 4 months in Europe.
Well, that isn't true. 40% of the courntries with land in Europe are neither in the EU or Schengen. So you can hang out in Zhalpaqtal, Kazakhstan for instance.
and plan on exiting the EU from Dublin hopefully 4 months after
entering
You will have to be sure that you limit your time in the Schengen countries to 90 days, which means if there is no other agreement that I dont know anything about, you will have to spend a bit more than a month in Ireland. Or possibly yoiu over simplified the post and you have a few other stops outside of the EU and Schengen along the way? In four months there is a lot that can be seen that will help on the time in Schengen .... Albania, Armenia, Azerbaijan, Belarus, Bosnia & Herzegovina, Georgia, Kazakhastan, N. Macedonia, Moldova, Montenegro, Serbia, Turkey, Ukraine, United Kingdom
I guess buying a refundable ticket to home might be good insurance.