RFR: 8376420: Remove AppContext from javax/swing/ImageIcon.java

Alexey Ivanov aivanov at openjdk.org
Wed Jan 28 20:12:38 UTC 2026


On Wed, 28 Jan 2026 19:39:21 GMT, Sergey Bylokhov <serb at openjdk.org> wrote:

> I am pretty sure this was AppContext related, since we could not return a MediaTracker stored in one AppContext to another AppContext and now we are doing exactly that, but ok not a big issue.

Very much likely.

Does an app need direct access to the `MediaTracker` that's used to download the image? Probably not, therefore a private member is better.

> The only difference between the two is that the old MediaTracker component was created using createComponent, which resets the AppContext, should we drop that AppContext usage there as well?

Indeed, the component created via `createComponent` doesn't store a reference to app context.

https://github.com/prrace/jdk/blob/08f95226d2c638cae74f51836b7fc509ed5b0b8b/src/java.desktop/share/classes/javax/swing/ImageIcon.java#L116-L119

I guess it'll get removed when the `appContext` field gets removed from `Component`.

On the other hand, the shared `MediaTracker` instance introduced in this PR could use `createComponent` to instead of creating a new instance of `Component`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29433#discussion_r2738423738


More information about the client-libs-dev mailing list