RFR: 8055461: getNextID in ImageIcon class can lead to overflow
Prasanta Sadhukhan
psadhukhan at openjdk.org
Mon Jun 9 02:16:50 UTC 2025
On Fri, 6 Jun 2025 08:47:33 GMT, Jeremy Wood <duke at 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..
>
> src/java.desktop/share/classes/javax/swing/ImageIcon.java line 305:
>
>> 303: return;
>> 304: }
>> 305: mTracker.addImage(image, id);
>
> Hmm. Is there any acceptable logging we could use here?
>
> (I'm just thinking: from the perspective of a developer trying to debug a customer complaint, this would be a lot easier to identify in System.err mentioned it...? Otherwise I'd start by trying to look for potential memory leaks or other red herrings.)
I dont think there is any logging for this nor do we want to log...In all probability, the image will consume the heap memory so practically OOM will be raised by the time this overflow happens but it can happen if maybe all 1x1 images are used and subsequent needed memory reserved for Java process
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25666#discussion_r2134929127
More information about the client-libs-dev
mailing list