Harsh prophecies are not necessarily absolute decrees. Instead, they serve primarily as warnings. The underlying principle is that if people turn away from their wrongdoings and repent, the difficult future foretold by the prophecy will not come to pass.
The primary approach among commentators is that King Josiah operates on this exact understanding. Recognizing the severe decree hanging over the nation, he makes every possible effort to change their destiny. To achieve this, he summons and gathers all the elders of Judah and Jerusalem. His ultimate goal is to awaken a spirit of repentance among the people and cancel the terrible decree.