RFR: 8055461: getNextID in ImageIcon class can lead to overflow

Alexey Ivanov aivanov at openjdk.org
Wed Jun 11 13:34:29 UTC 2025


On Wed, 11 Jun 2025 13:24:57 GMT, Prasanta Sadhukhan <psadhukhan at openjdk.org> wrote:

> > I think a better solution is to create a new MediaTracker, and start anew with id of zero.
> 
> So, we need to have mediaTrackerID1 and use that but then what about when next Integer.MAX_VALUE is reached, create another MediaTracker and again use another mediaTrackerID2 ? it will be a loop then... Won;t it better and simpler to make the id "long" which will make it use 2*64 images in one application?

No, just one.

When `mediaTrackerID` reaches `Integer.MAX_VALUE`, the `ImageIcon.getTracker` method will create a new `MediaTracker` and put it into `AppContext`, then it will reset the value of `mediaTrackerID` to 0 before returning the new instance of the media tracker.

-------------

PR Comment: https://git.openjdk.org/jdk/pull/25666#issuecomment-2962726712


More information about the client-libs-dev mailing list