RFR: 8378585: Mark fields in MediaTracker final

Phil Race prr at openjdk.org
Tue Feb 24 18:42:48 UTC 2026


On Tue, 24 Feb 2026 17:02:27 GMT, Alexey Ivanov <aivanov at openjdk.org> wrote:

> During the discussions in https://github.com/openjdk/jdk/pull/29433, I looked at the source code of `MediaTracker` and found several issues for cleaning up.
> 
> - The `target` field in `MediaTracker` is initialised in the constructor, it's never changed;
> - The visibility of the `head` field in `MediaTracker` can be reduced to `private`;
> - The `tracker` and `ID` fields in the `MediaEntry` class are never changed after being set in the constructor, therefore it's `final`;
> - The `getID` method of `MediaEntry` should be `final`, subclasses shouldn't be able to change the returned id;
> - The fields in `ImageMediaEntry`—`image`, `width` and `height`—can also be `final`.
> - The `ImageMediaEntry` class itself is `final`.
> 
> Additionally, I added the `@Override` annotation to overridden methods.

Marked as reviewed by prr (Reviewer).

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

PR Review: https://git.openjdk.org/jdk/pull/29899#pullrequestreview-3849863492


More information about the client-libs-dev mailing list