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

Prasanta Sadhukhan psadhukhan at openjdk.org
Wed Jun 11 03:11:29 UTC 2025


On Tue, 10 Jun 2025 13:12:20 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> 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.

If we create a new MediaTracker in ImageIcon and start anew with id of zero, then if application is having its own MediaTracker to track then when it calls for tracker.checkID(0) or tracker.statusID(0) then it will be confusing to which image it is referring to,
so I guess this current PR is more simpler in the sense it will notify ABORTED status for all images which overflows so that application can start anew with new ImageIcon and then use their MediaTracker to track this new ImageIcon.

Other thing that can be done is to modify "int" to "long" for all ids to further the overflow goalpost whereby `MediaTracker.checkID,addImage, statusID` signature will be changed..I dont think it will break any application but it will require CSR and since this issue is earmarked as Enhancement, maybe submitter also wanted that but I am not sure of going that route unless there is consensus on it..

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

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


More information about the client-libs-dev mailing list