On Fri, 6 Jun 2025 03:29:47 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> wrote:
> ImageIcon.getNextID uses `mediaTrackerID ` which do not detect overflow. > > Theoretically there is a possibility that there can be overflow in the long > time run or for large number of created "imageIcon" > > Made sure there is no overflow and treat that loadImage as ABORTED > > No regression testcase as it addresses theoretical possibility.. I think a better solution is to create a new `MediaTracker`, and start anew with id of zero. The `TRACKER_KEY` is used only by `ImageIcon`, so it shouldn't break any apps. src/java.desktop/share/classes/javax/swing/ImageIcon.java line 304: > 302: height = image.getHeight(imageObserver); > 303: return; > 304: } This means that the application won't be able to load images using `MediaTracker`. Is it really a problem that the id becomes negative? Does anything stop working? ~~I can't see that anything breaks because of that. The id is just an id, and it's compared for equality. (Although having a negative id could look suspicious.)~~ It may break at `MediaEntry` insertion, although it would still work probably… Another problem may occur if and when the id wraps around again to positive numbers and 0, 1… _are still being used_. ------------- Changes requested by aivanov (Reviewer). PR Review: https://git.openjdk.org/jdk/pull/25666#pullrequestreview-2913496159 PR Review Comment: https://git.openjdk.org/jdk/pull/25666#discussion_r2137855023