RFR: 8378585: Mark fields in MediaTracker final

Alexey Ivanov aivanov at openjdk.org
Tue Feb 24 17:10:28 UTC 2026


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.

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

Commit messages:
 - 8378585: Mark fields in MediaTracker final

Changes: https://git.openjdk.org/jdk/pull/29899/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=29899&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8378585
  Stats: 14 lines in 1 file changed: 4 ins; 0 del; 10 mod
  Patch: https://git.openjdk.org/jdk/pull/29899.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/29899/head:pull/29899

PR: https://git.openjdk.org/jdk/pull/29899


More information about the client-libs-dev mailing list