[foreign-memaccess+abi] RFR: 8290880: Add static MemorySegment::mismatch method

Paul Sandoz psandoz at openjdk.org
Fri Jul 22 17:49:15 UTC 2022


On Fri, 22 Jul 2022 16:29:46 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Re: static vs instance, apologies I don't mean to reopen that discussion.
>> 
>> IIRC the motivation for the signatures in `Arrays` was in part because that is the pattern used by all the other methods. You are right that the underlying primitive is passing in a common length, which is what the supporting internal mismatch methods use, but it may not be as helpful to require the user to compute the minimum length. To be honest I am torn between keeping close to the `copy` signature or using absolute ranges :-)
>
> One advantage to push the length computation inside is that explaining what the instance method does become trivial. An option could be to expose both, but seems like overkill. I think I'm fine with exposing the Arrays signature - after all the user can always get what he wants either way. That would at least make the API point consistent with Arrays.mismatch (in the same way MemorySegment::copy is consistent with System::arraycopy).

I agree with that positioning, `System::arraycopy` is to `MemorySegment::copy` as `Arrays::mistmatch` is to `MemorySegment::mistmatch`.

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

PR: https://git.openjdk.org/panama-foreign/pull/691


More information about the panama-dev mailing list