RFR: 8376582: Remove assert from default method in java.util.zip.Checksum interface
Alan Bateman
alanb at openjdk.org
Wed Jan 28 14:03:38 UTC 2026
On Wed, 28 Jan 2026 13:46:39 GMT, Eirik Bjørsnøs <eirbjo at openjdk.org> wrote:
> Please review this PR which removes an `assert` from the default method `Checksum::update(ByteBuffer)`.
>
> Since this is an interface, javac generates a synthetic inner class to capture the `$assertionsDisabled` information.
>
> This is the only use of assert within default methods in `java.base`.
>
> I do not think it carries its weight in terms of the loading the generated class, so I suggest we simply remove it. The method already returns when `pos > limit`.
>
> Trivial cleanup, `noreg-cleanup`.
src/java.base/share/classes/java/util/zip/Checksum.java line 108:
> 106: int pos = buffer.position();
> 107: int limit = buffer.limit();
> 108: assert (pos <= limit);
I assume the intention was to mutation of buffer in another thread.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/29466#discussion_r2736781219
More information about the core-libs-dev
mailing list