RFR: 8376582: Remove assert from default method in java.util.zip.Checksum interface
Eirik Bjørsnøs
eirbjo at openjdk.org
Wed Jan 28 21:48:27 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`.
I raised a question on `compiler-dev` about why these nested classes need to be eagerly i by the interface:
https://mail.openjdk.org/pipermail/compiler-dev/2026-January/032669.html
Perhaps we could defer initialization until execution of the asserting bytecode.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/29466#issuecomment-3814094705
More information about the core-libs-dev
mailing list